From 42e783930eb5aa244f85db412118b9afedb38128 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Fri, 26 May 2023 10:02:20 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Pick=20PR=20#54317=20(Resolve=20?= =?UTF-8?q?re-exports=20when=20looking=20for...)=20into=20release-5.1=20(#?= =?UTF-8?q?54327)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Andrew Branch --- src/compiler/checker.ts | 2 +- .../reference/tslibReExportHelpers.js | 39 +++++++++++++++++++ .../reference/tslibReExportHelpers.symbols | 19 +++++++++ .../reference/tslibReExportHelpers.types | 19 +++++++++ tests/cases/compiler/tslibReExportHelpers.ts | 29 ++++++++++++++ 5 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/tslibReExportHelpers.js create mode 100644 tests/baselines/reference/tslibReExportHelpers.symbols create mode 100644 tests/baselines/reference/tslibReExportHelpers.types create mode 100644 tests/cases/compiler/tslibReExportHelpers.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 36dad0b34b05d..1f2d87de5da94 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/baselines/reference/tslibReExportHelpers.js b/tests/baselines/reference/tslibReExportHelpers.js new file mode 100644 index 0000000000000..033bd963f07f1 --- /dev/null +++ b/tests/baselines/reference/tslibReExportHelpers.js @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/tslibReExportHelpers.ts] //// + +//// [index.d.ts] +export declare function __decorate(...args: any[]): any; + +//// [index.d.mts] +export * from "./index.js"; + +//// [package.json] +{ + "name": "tslib", + "version": "1.0.0", + "types": "index.d.ts", + "exports": { + ".": { + "types": { + "import": "./index.d.mts", + "default": "./index.d.ts" + } + } + } +} + +//// [index.mts] +declare var decorator: any; +@decorator +export class Foo {} + + +//// [index.mjs] +import { __decorate } from "tslib"; +export var Foo = /** @class */ (function () { + function Foo() { + } + Foo = __decorate([ + decorator + ], Foo); + return Foo; +}()); diff --git a/tests/baselines/reference/tslibReExportHelpers.symbols b/tests/baselines/reference/tslibReExportHelpers.symbols new file mode 100644 index 0000000000000..41a48704b1d7b --- /dev/null +++ b/tests/baselines/reference/tslibReExportHelpers.symbols @@ -0,0 +1,19 @@ +=== /node_modules/tslib/index.d.ts === +export declare function __decorate(...args: any[]): any; +>__decorate : Symbol(__decorate, Decl(index.d.ts, 0, 0)) +>args : Symbol(args, Decl(index.d.ts, 0, 35)) + +=== /node_modules/tslib/index.d.mts === + +export * from "./index.js"; + +=== /index.mts === +declare var decorator: any; +>decorator : Symbol(decorator, Decl(index.mts, 0, 11)) + +@decorator +>decorator : Symbol(decorator, Decl(index.mts, 0, 11)) + +export class Foo {} +>Foo : Symbol(Foo, Decl(index.mts, 0, 27)) + diff --git a/tests/baselines/reference/tslibReExportHelpers.types b/tests/baselines/reference/tslibReExportHelpers.types new file mode 100644 index 0000000000000..ca17052ccbcad --- /dev/null +++ b/tests/baselines/reference/tslibReExportHelpers.types @@ -0,0 +1,19 @@ +=== /node_modules/tslib/index.d.ts === +export declare function __decorate(...args: any[]): any; +>__decorate : (...args: any[]) => any +>args : any[] + +=== /node_modules/tslib/index.d.mts === + +export * from "./index.js"; + +=== /index.mts === +declare var decorator: any; +>decorator : any + +@decorator +>decorator : any + +export class Foo {} +>Foo : Foo + 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 {}