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.
This commit is contained in:
Nathan Shively-Sanders 2018-09-12 12:21:50 -07:00 committed by GitHub
parent 6bd1da20c9
commit 2f8a646f8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 1 deletions

View File

@ -28154,7 +28154,7 @@ namespace ts {
if (!symbol || !(symbol.flags & SymbolFlags.Function)) {
return false;
}
return !!forEachEntry(getExportsOfSymbol(symbol), p => isPropertyAccessExpression(p.valueDeclaration));
return !!forEachEntry(getExportsOfSymbol(symbol), p => p.flags & SymbolFlags.Value && isPropertyAccessExpression(p.valueDeclaration));
}
function getPropertiesOfContainerFunction(node: Declaration): Symbol[] {

View File

@ -0,0 +1,23 @@
//// [expando.ts]
// #27032
function ExpandoMerge(n: number) {
return n;
}
namespace ExpandoMerge {
export interface I { }
}
//// [expando.js]
// #27032
function ExpandoMerge(n) {
return n;
}
//// [expando.d.ts]
declare function ExpandoMerge(n: number): number;
declare namespace ExpandoMerge {
interface I {
}
}

View File

@ -0,0 +1,16 @@
=== tests/cases/compiler/expando.ts ===
// #27032
function ExpandoMerge(n: number) {
>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 1))
>n : Symbol(n, Decl(expando.ts, 1, 22))
return n;
>n : Symbol(n, Decl(expando.ts, 1, 22))
}
namespace ExpandoMerge {
>ExpandoMerge : Symbol(ExpandoMerge, Decl(expando.ts, 0, 0), Decl(expando.ts, 3, 1))
export interface I { }
>I : Symbol(I, Decl(expando.ts, 4, 24))
}

View File

@ -0,0 +1,13 @@
=== tests/cases/compiler/expando.ts ===
// #27032
function ExpandoMerge(n: number) {
>ExpandoMerge : (n: number) => number
>n : number
return n;
>n : number
}
namespace ExpandoMerge {
export interface I { }
}

View File

@ -0,0 +1,9 @@
// @declaration: true
// @Filename: expando.ts
// #27032
function ExpandoMerge(n: number) {
return n;
}
namespace ExpandoMerge {
export interface I { }
}