mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 13:45:34 -05:00
Ensure we find export default declaration targets if we search for them by name
This commit is contained in:
@@ -349,6 +349,13 @@ module ts {
|
||||
}
|
||||
result = undefined;
|
||||
}
|
||||
else if (location.kind === SyntaxKind.SourceFile) {
|
||||
result = getSymbol(getSymbolOfNode(location).exports, "default", meaning & SymbolFlags.ModuleMember);
|
||||
if (result && (result.flags & meaning) && result.valueDeclaration && (result.valueDeclaration.flags & NodeFlags.Default) && result.valueDeclaration.localSymbol.name === name) {
|
||||
break loop;
|
||||
}
|
||||
result = undefined;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & SymbolFlags.EnumMember)) {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//// [es5ExportDefaultClassDeclaration3.ts]
|
||||
|
||||
var before: C = new C();
|
||||
|
||||
export default class C {
|
||||
method(): C {
|
||||
return new C();
|
||||
}
|
||||
}
|
||||
|
||||
var after: C = new C();
|
||||
|
||||
var t: typeof C = C;
|
||||
|
||||
|
||||
|
||||
//// [es5ExportDefaultClassDeclaration3.js]
|
||||
var before = new C();
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.method = function () {
|
||||
return new C();
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
exports.default = C;
|
||||
var after = new C();
|
||||
var t = C;
|
||||
|
||||
|
||||
//// [es5ExportDefaultClassDeclaration3.d.ts]
|
||||
export default class C {
|
||||
method(): C;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
=== tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts ===
|
||||
|
||||
var before: C = new C();
|
||||
>before : C
|
||||
>C : C
|
||||
>new C() : C
|
||||
>C : typeof C
|
||||
|
||||
export default class C {
|
||||
>C : C
|
||||
|
||||
method(): C {
|
||||
>method : () => C
|
||||
>C : C
|
||||
|
||||
return new C();
|
||||
>new C() : C
|
||||
>C : typeof C
|
||||
}
|
||||
}
|
||||
|
||||
var after: C = new C();
|
||||
>after : C
|
||||
>C : C
|
||||
>new C() : C
|
||||
>C : typeof C
|
||||
|
||||
var t: typeof C = C;
|
||||
>t : typeof C
|
||||
>C : typeof C
|
||||
>C : typeof C
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [es5ExportDefaultFunctionDeclaration3.ts]
|
||||
|
||||
var before: typeof func = func();
|
||||
|
||||
export default function func(): typeof func {
|
||||
return func;
|
||||
}
|
||||
|
||||
var after: typeof func = func();
|
||||
|
||||
//// [es5ExportDefaultFunctionDeclaration3.js]
|
||||
var before = func();
|
||||
function func() {
|
||||
return func;
|
||||
}
|
||||
exports.default = func;
|
||||
var after = func();
|
||||
|
||||
|
||||
//// [es5ExportDefaultFunctionDeclaration3.d.ts]
|
||||
export default function func(): typeof func;
|
||||
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/es5ExportDefaultFunctionDeclaration3.ts ===
|
||||
|
||||
var before: typeof func = func();
|
||||
>before : () => typeof func
|
||||
>func : () => typeof func
|
||||
>func() : () => typeof func
|
||||
>func : () => typeof func
|
||||
|
||||
export default function func(): typeof func {
|
||||
>func : () => typeof func
|
||||
>func : () => typeof func
|
||||
|
||||
return func;
|
||||
>func : () => typeof func
|
||||
}
|
||||
|
||||
var after: typeof func = func();
|
||||
>after : () => typeof func
|
||||
>func : () => typeof func
|
||||
>func() : () => typeof func
|
||||
>func : () => typeof func
|
||||
|
||||
16
tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts
Normal file
16
tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
|
||||
var before: C = new C();
|
||||
|
||||
export default class C {
|
||||
method(): C {
|
||||
return new C();
|
||||
}
|
||||
}
|
||||
|
||||
var after: C = new C();
|
||||
|
||||
var t: typeof C = C;
|
||||
|
||||
11
tests/cases/compiler/es5ExportDefaultFunctionDeclaration3.ts
Normal file
11
tests/cases/compiler/es5ExportDefaultFunctionDeclaration3.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
|
||||
var before: typeof func = func();
|
||||
|
||||
export default function func(): typeof func {
|
||||
return func;
|
||||
}
|
||||
|
||||
var after: typeof func = func();
|
||||
Reference in New Issue
Block a user