Skip to content

Commit

Permalink
Elide re-exports of unresolved type-only imports (#56449)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbranch committed Nov 17, 2023
1 parent e2a5d45 commit 369ec84
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47515,7 +47515,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
const target = getExportSymbolOfValueSymbolIfExported(resolveAlias(symbol));
if (target === unknownSymbol) {
return true;
return !excludeTypeOnlyValues || !getTypeOnlyAliasDeclaration(symbol);
}
// const enums and modules that contain only const enums are not considered values from the emit perspective
// unless 'preserveConstEnums' option is set to true
Expand Down
11 changes: 11 additions & 0 deletions src/testRunner/unittests/services/transpile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,4 +662,15 @@ export * as alias from './file';`,
testVerbatimModuleSyntax: true,
},
);

transpilesCorrectly(
"Elides re-export of type-only import",
`
import type { Foo } from "./types";
export { Foo };
`,
{
options: { compilerOptions: { module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.ESNext } },
},
);
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 369ec84

Please sign in to comment.