diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 560783a71b58d..9ad699f1adcb0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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 diff --git a/src/testRunner/unittests/services/transpile.ts b/src/testRunner/unittests/services/transpile.ts index ddb040d7af356..a5d4efaf0b395 100644 --- a/src/testRunner/unittests/services/transpile.ts +++ b/src/testRunner/unittests/services/transpile.ts @@ -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 } }, + }, + ); }); diff --git a/tests/baselines/reference/transpile/Elides re-export of type-only import.js b/tests/baselines/reference/transpile/Elides re-export of type-only import.js new file mode 100644 index 0000000000000..e113dbc728253 --- /dev/null +++ b/tests/baselines/reference/transpile/Elides re-export of type-only import.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Elides re-export of type-only import.oldTranspile.js b/tests/baselines/reference/transpile/Elides re-export of type-only import.oldTranspile.js new file mode 100644 index 0000000000000..e113dbc728253 --- /dev/null +++ b/tests/baselines/reference/transpile/Elides re-export of type-only import.oldTranspile.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=file.js.map \ No newline at end of file