Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Pick PR #54317 (Resolve re-exports when looking for...) into release-5.1 #54327

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
39 changes: 39 additions & 0 deletions tests/baselines/reference/tslibReExportHelpers.js
Original file line number Diff line number Diff line change
@@ -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;
}());
19 changes: 19 additions & 0 deletions tests/baselines/reference/tslibReExportHelpers.symbols
Original file line number Diff line number Diff line change
@@ -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))

19 changes: 19 additions & 0 deletions tests/baselines/reference/tslibReExportHelpers.types
Original file line number Diff line number Diff line change
@@ -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

29 changes: 29 additions & 0 deletions tests/cases/compiler/tslibReExportHelpers.ts
Original file line number Diff line number Diff line change
@@ -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 {}