Skip to content

Commit 2f8a646

Browse files
authored
isExpandoFunctionDeclaration only checks values (#27052)
Previously it checked types too, which caused a crash because types don't have valueDeclaration set. But expando functions can't export types, only values.
1 parent 6bd1da2 commit 2f8a646

File tree

5 files changed

+62
-1
lines changed

5 files changed

+62
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28154,7 +28154,7 @@ namespace ts {
2815428154
if (!symbol || !(symbol.flags & SymbolFlags.Function)) {
2815528155
return false;
2815628156
}
28157-
return !!forEachEntry(getExportsOfSymbol(symbol), p => isPropertyAccessExpression(p.valueDeclaration));
28157+
return !!forEachEntry(getExportsOfSymbol(symbol), p => p.flags & SymbolFlags.Value && isPropertyAccessExpression(p.valueDeclaration));
2815828158
}
2815928159

2816028160
function getPropertiesOfContainerFunction(node: Declaration): Symbol[] {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//// [expando.ts]
2+
// #27032
3+
function ExpandoMerge(n: number) {
4+
return n;
5+
}
6+
namespace ExpandoMerge {
7+
export interface I { }
8+
}
9+
10+
11+
//// [expando.js]
12+
// #27032
13+
function ExpandoMerge(n) {
14+
return n;
15+
}
16+
17+
18+
//// [expando.d.ts]
19+
declare function ExpandoMerge(n: number): number;
20+
declare namespace ExpandoMerge {
21+
interface I {
22+
}
23+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/compiler/expando.ts ===
2+
// #27032
3+
function ExpandoMerge(n: number) {
4+
>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 1))
5+
>n : Symbol(n, Decl(expando.ts, 1, 22))
6+
7+
return n;
8+
>n : Symbol(n, Decl(expando.ts, 1, 22))
9+
}
10+
namespace ExpandoMerge {
11+
>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 1))
12+
13+
export interface I { }
14+
>I : Symbol(I, Decl(expando.ts, 4, 24))
15+
}
16+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/compiler/expando.ts ===
2+
// #27032
3+
function ExpandoMerge(n: number) {
4+
>ExpandoMerge : (n: number) => number
5+
>n : number
6+
7+
return n;
8+
>n : number
9+
}
10+
namespace ExpandoMerge {
11+
export interface I { }
12+
}
13+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// @declaration: true
2+
// @Filename: expando.ts
3+
// #27032
4+
function ExpandoMerge(n: number) {
5+
return n;
6+
}
7+
namespace ExpandoMerge {
8+
export interface I { }
9+
}

0 commit comments

Comments
 (0)