Skip to content

Fix assert with declaration emit for export specifier for a global #3641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,9 @@ namespace ts {

// Check if symbol is any of the alias
return forEachValue(symbols, symbolFromSymbolTable => {
if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.name !== "export=") {
if (symbolFromSymbolTable.flags & SymbolFlags.Alias
&& symbolFromSymbolTable.name !== "export="
&& !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) {
if (!useOnlyExternalAliasing || // We can use any type of alias to get the name
// Is this external alias, then use it to name
ts.forEach(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration)) {
Expand Down Expand Up @@ -1207,7 +1209,7 @@ namespace ts {
}

// Qualify if the symbol from symbol table has same meaning as expected
symbolFromSymbolTable = (symbolFromSymbolTable.flags & SymbolFlags.Alias) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
symbolFromSymbolTable = (symbolFromSymbolTable.flags & SymbolFlags.Alias && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
if (symbolFromSymbolTable.flags & meaning) {
qualify = true;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export { c as c2 } from "server";

export { i, m as instantiatedModule } from "server";
>i : any
>m : typeof instantiatedModule
>instantiatedModule : typeof instantiatedModule
>m : typeof m
>instantiatedModule : typeof m

export { uninstantiated } from "server";
>uninstantiated : any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export { c as c2 } from "server";

export { i, m as instantiatedModule } from "server";
>i : any
>m : typeof instantiatedModule
>instantiatedModule : typeof instantiatedModule
>m : typeof m
>instantiatedModule : typeof m

export { uninstantiated } from "server";
>uninstantiated : any
Expand Down
25 changes: 25 additions & 0 deletions tests/baselines/reference/exportSpecifierForAGlobal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//// [tests/cases/compiler/exportSpecifierForAGlobal.ts] ////

//// [a.d.ts]

declare class X { }

//// [b.ts]
export {X};
export function f() {
var x: X;
return x;
}


//// [b.js]
function f() {
var x;
return x;
}
exports.f = f;


//// [b.d.ts]
export { X };
export declare function f(): X;
20 changes: 20 additions & 0 deletions tests/baselines/reference/exportSpecifierForAGlobal.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
=== tests/cases/compiler/a.d.ts ===

declare class X { }
>X : Symbol(X, Decl(a.d.ts, 0, 0))

=== tests/cases/compiler/b.ts ===
export {X};
>X : Symbol(X, Decl(b.ts, 0, 8))

export function f() {
>f : Symbol(f, Decl(b.ts, 0, 11))

var x: X;
>x : Symbol(x, Decl(b.ts, 2, 7))
>X : Symbol(X, Decl(a.d.ts, 0, 0))

return x;
>x : Symbol(x, Decl(b.ts, 2, 7))
}

20 changes: 20 additions & 0 deletions tests/baselines/reference/exportSpecifierForAGlobal.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
=== tests/cases/compiler/a.d.ts ===

declare class X { }
>X : X

=== tests/cases/compiler/b.ts ===
export {X};
>X : typeof X

export function f() {
>f : () => X

var x: X;
>x : X
>X : X

return x;
>x : X
}

12 changes: 6 additions & 6 deletions tests/baselines/reference/exportsAndImports3-amd.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ export enum E {
>E : Symbol(E, Decl(t1.ts, 6, 1))

A, B, C
>A : Symbol(E1.A, Decl(t1.ts, 7, 15))
>B : Symbol(E1.B, Decl(t1.ts, 8, 6))
>C : Symbol(E1.C, Decl(t1.ts, 8, 9))
>A : Symbol(E.A, Decl(t1.ts, 7, 15))
>B : Symbol(E.B, Decl(t1.ts, 8, 6))
>C : Symbol(E.C, Decl(t1.ts, 8, 9))
}
export const enum D {
>D : Symbol(D, Decl(t1.ts, 9, 1))

A, B, C
>A : Symbol(D1.A, Decl(t1.ts, 10, 21))
>B : Symbol(D1.B, Decl(t1.ts, 11, 6))
>C : Symbol(D1.C, Decl(t1.ts, 11, 9))
>A : Symbol(D.A, Decl(t1.ts, 10, 21))
>B : Symbol(D.B, Decl(t1.ts, 11, 6))
>C : Symbol(D.C, Decl(t1.ts, 11, 9))
}
export module M {
>M : Symbol(M, Decl(t1.ts, 12, 1))
Expand Down
12 changes: 6 additions & 6 deletions tests/baselines/reference/exportsAndImports3.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ export enum E {
>E : Symbol(E, Decl(t1.ts, 6, 1))

A, B, C
>A : Symbol(E1.A, Decl(t1.ts, 7, 15))
>B : Symbol(E1.B, Decl(t1.ts, 8, 6))
>C : Symbol(E1.C, Decl(t1.ts, 8, 9))
>A : Symbol(E.A, Decl(t1.ts, 7, 15))
>B : Symbol(E.B, Decl(t1.ts, 8, 6))
>C : Symbol(E.C, Decl(t1.ts, 8, 9))
}
export const enum D {
>D : Symbol(D, Decl(t1.ts, 9, 1))

A, B, C
>A : Symbol(D1.A, Decl(t1.ts, 10, 21))
>B : Symbol(D1.B, Decl(t1.ts, 11, 6))
>C : Symbol(D1.C, Decl(t1.ts, 11, 9))
>A : Symbol(D.A, Decl(t1.ts, 10, 21))
>B : Symbol(D.B, Decl(t1.ts, 11, 6))
>C : Symbol(D.C, Decl(t1.ts, 11, 9))
}
export module M {
>M : Symbol(M, Decl(t1.ts, 12, 1))
Expand Down
12 changes: 12 additions & 0 deletions tests/cases/compiler/exportSpecifierForAGlobal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @declaration: true
// @module: commonjs

// @filename: a.d.ts
declare class X { }

// @filename: b.ts
export {X};
export function f() {
var x: X;
return x;
}