Skip to content

Commit 7893c9f

Browse files
authored
Do not add reexported names to the exportSpecifiers list of moduleinfo (microsoft#39213)
1 parent 5d9b785 commit 7893c9f

File tree

5 files changed

+92
-3
lines changed

5 files changed

+92
-3
lines changed

src/compiler/transformers/utilities.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace ts {
88
export interface ExternalModuleInfo {
99
externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; // imports of other external modules
1010
externalHelpersImportDeclaration: ImportDeclaration | undefined; // import of external helpers
11-
exportSpecifiers: Map<ExportSpecifier[]>; // export specifiers by name
11+
exportSpecifiers: Map<ExportSpecifier[]>; // file-local export specifiers by name (no reexports)
1212
exportedBindings: Identifier[][]; // exported names of local declarations
13-
exportedNames: Identifier[] | undefined; // all exported names local to module
13+
exportedNames: Identifier[] | undefined; // all exported names in the module, both local and reexported
1414
exportEquals: ExportAssignment | undefined; // an export= declaration if one was present
1515
hasExportStarsToExportValues: boolean; // whether this module contains export*
1616
}
@@ -201,7 +201,9 @@ namespace ts {
201201
for (const specifier of cast(node.exportClause, isNamedExports).elements) {
202202
if (!uniqueExports.get(idText(specifier.name))) {
203203
const name = specifier.propertyName || specifier.name;
204-
exportSpecifiers.add(idText(name), specifier);
204+
if (!node.moduleSpecifier) {
205+
exportSpecifiers.add(idText(name), specifier);
206+
}
205207

206208
const decl = resolver.getReferencedImportDeclaration(name)
207209
|| resolver.getReferencedValueDeclaration(name);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//// [tests/cases/compiler/reexportNameAliasedAndHoisted.ts] ////
2+
3+
//// [gridview.ts]
4+
export type Sizing = any;
5+
export const Sizing = null;
6+
//// [index.ts]
7+
// https://github.com/microsoft/TypeScript/issues/39195
8+
export { Sizing as GridViewSizing } from './gridview';
9+
export namespace Sizing {
10+
export const Distribute = { type: 'distribute' };
11+
}
12+
13+
//// [gridview.js]
14+
"use strict";
15+
exports.__esModule = true;
16+
exports.Sizing = void 0;
17+
exports.Sizing = null;
18+
//// [index.js]
19+
"use strict";
20+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21+
if (k2 === undefined) k2 = k;
22+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
23+
}) : (function(o, m, k, k2) {
24+
if (k2 === undefined) k2 = k;
25+
o[k2] = m[k];
26+
}));
27+
exports.__esModule = true;
28+
exports.Sizing = exports.GridViewSizing = void 0;
29+
// https://github.com/microsoft/TypeScript/issues/39195
30+
var gridview_1 = require("./gridview");
31+
__createBinding(exports, gridview_1, "Sizing", "GridViewSizing");
32+
var Sizing;
33+
(function (Sizing) {
34+
Sizing.Distribute = { type: 'distribute' };
35+
})(Sizing = exports.Sizing || (exports.Sizing = {}));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
=== tests/cases/compiler/gridview.ts ===
2+
export type Sizing = any;
3+
>Sizing : Symbol(Sizing, Decl(gridview.ts, 0, 0), Decl(gridview.ts, 1, 12))
4+
5+
export const Sizing = null;
6+
>Sizing : Symbol(Sizing, Decl(gridview.ts, 0, 0), Decl(gridview.ts, 1, 12))
7+
8+
=== tests/cases/compiler/index.ts ===
9+
// https://github.com/microsoft/TypeScript/issues/39195
10+
export { Sizing as GridViewSizing } from './gridview';
11+
>Sizing : Symbol(Sizing, Decl(gridview.ts, 0, 0), Decl(gridview.ts, 1, 12))
12+
>GridViewSizing : Symbol(GridViewSizing, Decl(index.ts, 1, 8))
13+
14+
export namespace Sizing {
15+
>Sizing : Symbol(Sizing, Decl(index.ts, 1, 54))
16+
17+
export const Distribute = { type: 'distribute' };
18+
>Distribute : Symbol(Distribute, Decl(index.ts, 3, 16))
19+
>type : Symbol(type, Decl(index.ts, 3, 31))
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
=== tests/cases/compiler/gridview.ts ===
2+
export type Sizing = any;
3+
>Sizing : any
4+
5+
export const Sizing = null;
6+
>Sizing : any
7+
>null : null
8+
9+
=== tests/cases/compiler/index.ts ===
10+
// https://github.com/microsoft/TypeScript/issues/39195
11+
export { Sizing as GridViewSizing } from './gridview';
12+
>Sizing : any
13+
>GridViewSizing : any
14+
15+
export namespace Sizing {
16+
>Sizing : typeof Sizing
17+
18+
export const Distribute = { type: 'distribute' };
19+
>Distribute : { type: string; }
20+
>{ type: 'distribute' } : { type: string; }
21+
>type : string
22+
>'distribute' : "distribute"
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// @filename: gridview.ts
2+
export type Sizing = any;
3+
export const Sizing = null;
4+
// @filename: index.ts
5+
// https://github.com/microsoft/TypeScript/issues/39195
6+
export { Sizing as GridViewSizing } from './gridview';
7+
export namespace Sizing {
8+
export const Distribute = { type: 'distribute' };
9+
}

0 commit comments

Comments
 (0)