From 18b8b631f1770f34b486fbfc8c6791d568c902c5 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 18 May 2023 15:55:34 -0700 Subject: [PATCH] Resolve re-exports when looking for tslib helpers --- src/compiler/checker.ts | 2 +- tests/cases/compiler/tslibReExportHelpers.ts | 29 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/cases/compiler/tslibReExportHelpers.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ca6ab49708c75..ca9fb2f96d75b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -46998,7 +46998,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (requestedExternalEmitHelperNames.has(name)) continue; requestedExternalEmitHelperNames.add(name); - const symbol = getSymbol(helpersModule.exports!, escapeLeadingUnderscores(name), SymbolFlags.Value); + const symbol = getSymbol(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), SymbolFlags.Value); if (!symbol) { error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name); } diff --git a/tests/cases/compiler/tslibReExportHelpers.ts b/tests/cases/compiler/tslibReExportHelpers.ts new file mode 100644 index 0000000000000..94384bdd8fccc --- /dev/null +++ b/tests/cases/compiler/tslibReExportHelpers.ts @@ -0,0 +1,29 @@ +// @module: nodenext +// @experimentalDecorators: true +// @importHelpers: true + +// @Filename: /node_modules/tslib/index.d.ts +export declare function __decorate(...args: any[]): any; + +// @Filename: /node_modules/tslib/index.d.mts +export * from "./index.js"; + +// @Filename: /node_modules/tslib/package.json +{ + "name": "tslib", + "version": "1.0.0", + "types": "index.d.ts", + "exports": { + ".": { + "types": { + "import": "./index.d.mts", + "default": "./index.d.ts" + } + } + } +} + +// @Filename: /index.mts +declare var decorator: any; +@decorator +export class Foo {}