Skip to content

Commit 066bb16

Browse files
author
Andy
authored
Merge pull request #15539 from Microsoft/isolated-modules_export-star
Never elide an `export *` when `--isolatedModules` is set
2 parents 2ba89fc + e696bbc commit 066bb16

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-1
lines changed

src/compiler/transformers/ts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2918,7 +2918,7 @@ namespace ts {
29182918
function visitExportDeclaration(node: ExportDeclaration): VisitResult<Statement> {
29192919
if (!node.exportClause) {
29202920
// Elide a star export if the module it references does not export a value.
2921-
return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined;
2921+
return compilerOptions.isolatedModules || resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined;
29222922
}
29232923

29242924
if (!resolver.isValueAliasDeclaration(node)) {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//// [tests/cases/compiler/isolatedModulesDontElideReExportStar.ts] ////
2+
3+
//// [a.ts]
4+
export type T = number;
5+
6+
//// [b.ts]
7+
export * from "./a";
8+
9+
10+
//// [a.js]
11+
//// [b.js]
12+
export * from "./a";
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== /a.ts ===
2+
export type T = number;
3+
>T : Symbol(T, Decl(a.ts, 0, 0))
4+
5+
=== /b.ts ===
6+
export * from "./a";
7+
No type information for this code.
8+
No type information for this code.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== /a.ts ===
2+
export type T = number;
3+
>T : number
4+
5+
=== /b.ts ===
6+
export * from "./a";
7+
No type information for this code.
8+
No type information for this code.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @isolatedModules: true
2+
// @target: es6
3+
4+
// @filename: /a.ts
5+
export type T = number;
6+
7+
// @filename: /b.ts
8+
export * from "./a";

0 commit comments

Comments
 (0)