Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe46122

Browse filesBrowse files
committed
Merge pull request microsoft#3641 from Microsoft/exportSepcifierInDeclarations
Fix assert with declaration emit for export specifier for a global
2 parents e1c9d28 + f9de30c commit fe46122
Copy full SHA for fe46122

9 files changed

+97-18Lines changed: 97 additions & 18 deletions
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/checker.ts‎

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,9 @@ namespace ts {
11831183

11841184
// Check if symbol is any of the alias
11851185
return forEachValue(symbols, symbolFromSymbolTable => {
1186-
if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.name !== "export=") {
1186+
if (symbolFromSymbolTable.flags & SymbolFlags.Alias
1187+
&& symbolFromSymbolTable.name !== "export="
1188+
&& !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) {
11871189
if (!useOnlyExternalAliasing || // We can use any type of alias to get the name
11881190
// Is this external alias, then use it to name
11891191
ts.forEach(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration)) {
@@ -1225,7 +1227,7 @@ namespace ts {
12251227
}
12261228

12271229
// Qualify if the symbol from symbol table has same meaning as expected
1228-
symbolFromSymbolTable = (symbolFromSymbolTable.flags & SymbolFlags.Alias) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
1230+
symbolFromSymbolTable = (symbolFromSymbolTable.flags & SymbolFlags.Alias && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
12291231
if (symbolFromSymbolTable.flags & meaning) {
12301232
qualify = true;
12311233
return true;
Collapse file

‎tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export { c as c2 } from "server";
3131

3232
export { i, m as instantiatedModule } from "server";
3333
>i : any
34-
>m : typeof instantiatedModule
35-
>instantiatedModule : typeof instantiatedModule
34+
>m : typeof m
35+
>instantiatedModule : typeof m
3636

3737
export { uninstantiated } from "server";
3838
>uninstantiated : any
Collapse file

‎tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export { c as c2 } from "server";
3131

3232
export { i, m as instantiatedModule } from "server";
3333
>i : any
34-
>m : typeof instantiatedModule
35-
>instantiatedModule : typeof instantiatedModule
34+
>m : typeof m
35+
>instantiatedModule : typeof m
3636

3737
export { uninstantiated } from "server";
3838
>uninstantiated : any
Collapse file
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//// [tests/cases/compiler/exportSpecifierForAGlobal.ts] ////
2+
3+
//// [a.d.ts]
4+
5+
declare class X { }
6+
7+
//// [b.ts]
8+
export {X};
9+
export function f() {
10+
var x: X;
11+
return x;
12+
}
13+
14+
15+
//// [b.js]
16+
function f() {
17+
var x;
18+
return x;
19+
}
20+
exports.f = f;
21+
22+
23+
//// [b.d.ts]
24+
export { X };
25+
export declare function f(): X;
Collapse file
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
=== tests/cases/compiler/a.d.ts ===
2+
3+
declare class X { }
4+
>X : Symbol(X, Decl(a.d.ts, 0, 0))
5+
6+
=== tests/cases/compiler/b.ts ===
7+
export {X};
8+
>X : Symbol(X, Decl(b.ts, 0, 8))
9+
10+
export function f() {
11+
>f : Symbol(f, Decl(b.ts, 0, 11))
12+
13+
var x: X;
14+
>x : Symbol(x, Decl(b.ts, 2, 7))
15+
>X : Symbol(X, Decl(a.d.ts, 0, 0))
16+
17+
return x;
18+
>x : Symbol(x, Decl(b.ts, 2, 7))
19+
}
20+
Collapse file
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
=== tests/cases/compiler/a.d.ts ===
2+
3+
declare class X { }
4+
>X : X
5+
6+
=== tests/cases/compiler/b.ts ===
7+
export {X};
8+
>X : typeof X
9+
10+
export function f() {
11+
>f : () => X
12+
13+
var x: X;
14+
>x : X
15+
>X : X
16+
17+
return x;
18+
>x : X
19+
}
20+
Collapse file

‎tests/baselines/reference/exportsAndImports3-amd.symbols‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/exportsAndImports3-amd.symbols
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ export enum E {
1616
>E : Symbol(E, Decl(t1.ts, 6, 1))
1717

1818
A, B, C
19-
>A : Symbol(E1.A, Decl(t1.ts, 7, 15))
20-
>B : Symbol(E1.B, Decl(t1.ts, 8, 6))
21-
>C : Symbol(E1.C, Decl(t1.ts, 8, 9))
19+
>A : Symbol(E.A, Decl(t1.ts, 7, 15))
20+
>B : Symbol(E.B, Decl(t1.ts, 8, 6))
21+
>C : Symbol(E.C, Decl(t1.ts, 8, 9))
2222
}
2323
export const enum D {
2424
>D : Symbol(D, Decl(t1.ts, 9, 1))
2525

2626
A, B, C
27-
>A : Symbol(D1.A, Decl(t1.ts, 10, 21))
28-
>B : Symbol(D1.B, Decl(t1.ts, 11, 6))
29-
>C : Symbol(D1.C, Decl(t1.ts, 11, 9))
27+
>A : Symbol(D.A, Decl(t1.ts, 10, 21))
28+
>B : Symbol(D.B, Decl(t1.ts, 11, 6))
29+
>C : Symbol(D.C, Decl(t1.ts, 11, 9))
3030
}
3131
export module M {
3232
>M : Symbol(M, Decl(t1.ts, 12, 1))
Collapse file

‎tests/baselines/reference/exportsAndImports3.symbols‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/exportsAndImports3.symbols
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ export enum E {
1616
>E : Symbol(E, Decl(t1.ts, 6, 1))
1717

1818
A, B, C
19-
>A : Symbol(E1.A, Decl(t1.ts, 7, 15))
20-
>B : Symbol(E1.B, Decl(t1.ts, 8, 6))
21-
>C : Symbol(E1.C, Decl(t1.ts, 8, 9))
19+
>A : Symbol(E.A, Decl(t1.ts, 7, 15))
20+
>B : Symbol(E.B, Decl(t1.ts, 8, 6))
21+
>C : Symbol(E.C, Decl(t1.ts, 8, 9))
2222
}
2323
export const enum D {
2424
>D : Symbol(D, Decl(t1.ts, 9, 1))
2525

2626
A, B, C
27-
>A : Symbol(D1.A, Decl(t1.ts, 10, 21))
28-
>B : Symbol(D1.B, Decl(t1.ts, 11, 6))
29-
>C : Symbol(D1.C, Decl(t1.ts, 11, 9))
27+
>A : Symbol(D.A, Decl(t1.ts, 10, 21))
28+
>B : Symbol(D.B, Decl(t1.ts, 11, 6))
29+
>C : Symbol(D.C, Decl(t1.ts, 11, 9))
3030
}
3131
export module M {
3232
>M : Symbol(M, Decl(t1.ts, 12, 1))
Collapse file
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// @declaration: true
2+
// @module: commonjs
3+
4+
// @filename: a.d.ts
5+
declare class X { }
6+
7+
// @filename: b.ts
8+
export {X};
9+
export function f() {
10+
var x: X;
11+
return x;
12+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.