Skip to content

Do not add reexported names to the exportSpecifiers list of moduleinfo #39213

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
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
8 changes: 5 additions & 3 deletions src/compiler/transformers/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace ts {
export interface ExternalModuleInfo {
externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; // imports of other external modules
externalHelpersImportDeclaration: ImportDeclaration | undefined; // import of external helpers
exportSpecifiers: Map<ExportSpecifier[]>; // export specifiers by name
exportSpecifiers: Map<ExportSpecifier[]>; // file-local export specifiers by name (no reexports)
exportedBindings: Identifier[][]; // exported names of local declarations
exportedNames: Identifier[] | undefined; // all exported names local to module
exportedNames: Identifier[] | undefined; // all exported names in the module, both local and reexported
exportEquals: ExportAssignment | undefined; // an export= declaration if one was present
hasExportStarsToExportValues: boolean; // whether this module contains export*
}
Expand Down Expand Up @@ -201,7 +201,9 @@ namespace ts {
for (const specifier of cast(node.exportClause, isNamedExports).elements) {
if (!uniqueExports.get(idText(specifier.name))) {
const name = specifier.propertyName || specifier.name;
exportSpecifiers.add(idText(name), specifier);
if (!node.moduleSpecifier) {
exportSpecifiers.add(idText(name), specifier);
}

const decl = resolver.getReferencedImportDeclaration(name)
|| resolver.getReferencedValueDeclaration(name);
Expand Down
35 changes: 35 additions & 0 deletions tests/baselines/reference/reexportNameAliasedAndHoisted.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//// [tests/cases/compiler/reexportNameAliasedAndHoisted.ts] ////

//// [gridview.ts]
export type Sizing = any;
export const Sizing = null;
//// [index.ts]
// https://github.com/microsoft/TypeScript/issues/39195
export { Sizing as GridViewSizing } from './gridview';
export namespace Sizing {
export const Distribute = { type: 'distribute' };
}

//// [gridview.js]
"use strict";
exports.__esModule = true;
exports.Sizing = void 0;
exports.Sizing = null;
//// [index.js]
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
exports.__esModule = true;
exports.Sizing = exports.GridViewSizing = void 0;
// https://github.com/microsoft/TypeScript/issues/39195
var gridview_1 = require("./gridview");
__createBinding(exports, gridview_1, "Sizing", "GridViewSizing");
var Sizing;
(function (Sizing) {
Sizing.Distribute = { type: 'distribute' };
})(Sizing = exports.Sizing || (exports.Sizing = {}));
20 changes: 20 additions & 0 deletions tests/baselines/reference/reexportNameAliasedAndHoisted.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
=== tests/cases/compiler/gridview.ts ===
export type Sizing = any;
>Sizing : Symbol(Sizing, Decl(gridview.ts, 0, 0), Decl(gridview.ts, 1, 12))

export const Sizing = null;
>Sizing : Symbol(Sizing, Decl(gridview.ts, 0, 0), Decl(gridview.ts, 1, 12))

=== tests/cases/compiler/index.ts ===
// https://github.com/microsoft/TypeScript/issues/39195
export { Sizing as GridViewSizing } from './gridview';
>Sizing : Symbol(Sizing, Decl(gridview.ts, 0, 0), Decl(gridview.ts, 1, 12))
>GridViewSizing : Symbol(GridViewSizing, Decl(index.ts, 1, 8))

export namespace Sizing {
>Sizing : Symbol(Sizing, Decl(index.ts, 1, 54))

export const Distribute = { type: 'distribute' };
>Distribute : Symbol(Distribute, Decl(index.ts, 3, 16))
>type : Symbol(type, Decl(index.ts, 3, 31))
}
23 changes: 23 additions & 0 deletions tests/baselines/reference/reexportNameAliasedAndHoisted.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
=== tests/cases/compiler/gridview.ts ===
export type Sizing = any;
>Sizing : any

export const Sizing = null;
>Sizing : any
>null : null

=== tests/cases/compiler/index.ts ===
// https://github.com/microsoft/TypeScript/issues/39195
export { Sizing as GridViewSizing } from './gridview';
>Sizing : any
>GridViewSizing : any

export namespace Sizing {
>Sizing : typeof Sizing

export const Distribute = { type: 'distribute' };
>Distribute : { type: string; }
>{ type: 'distribute' } : { type: string; }
>type : string
>'distribute' : "distribute"
}
9 changes: 9 additions & 0 deletions tests/cases/compiler/reexportNameAliasedAndHoisted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @filename: gridview.ts
export type Sizing = any;
export const Sizing = null;
// @filename: index.ts
// https://github.com/microsoft/TypeScript/issues/39195
export { Sizing as GridViewSizing } from './gridview';
export namespace Sizing {
export const Distribute = { type: 'distribute' };
}