Skip to content

Commit 818ff18

Browse files
andrewbranchtypescript-bot
authored andcommitted
Cherry-pick PR microsoft#54317 into release-5.1
Component commits: 18b8b63 Resolve re-exports when looking for tslib helpers 2d702aa Accept baselines
1 parent 7e48587 commit 818ff18

File tree

5 files changed

+107
-1
lines changed

5 files changed

+107
-1
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46998,7 +46998,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4699846998
if (requestedExternalEmitHelperNames.has(name)) continue;
4699946999
requestedExternalEmitHelperNames.add(name);
4700047000

47001-
const symbol = getSymbol(helpersModule.exports!, escapeLeadingUnderscores(name), SymbolFlags.Value);
47001+
const symbol = getSymbol(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), SymbolFlags.Value);
4700247002
if (!symbol) {
4700347003
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);
4700447004
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//// [tests/cases/compiler/tslibReExportHelpers.ts] ////
2+
3+
//// [index.d.ts]
4+
export declare function __decorate(...args: any[]): any;
5+
6+
//// [index.d.mts]
7+
export * from "./index.js";
8+
9+
//// [package.json]
10+
{
11+
"name": "tslib",
12+
"version": "1.0.0",
13+
"types": "index.d.ts",
14+
"exports": {
15+
".": {
16+
"types": {
17+
"import": "./index.d.mts",
18+
"default": "./index.d.ts"
19+
}
20+
}
21+
}
22+
}
23+
24+
//// [index.mts]
25+
declare var decorator: any;
26+
@decorator
27+
export class Foo {}
28+
29+
30+
//// [index.mjs]
31+
import { __decorate } from "tslib";
32+
export var Foo = /** @class */ (function () {
33+
function Foo() {
34+
}
35+
Foo = __decorate([
36+
decorator
37+
], Foo);
38+
return Foo;
39+
}());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== /node_modules/tslib/index.d.ts ===
2+
export declare function __decorate(...args: any[]): any;
3+
>__decorate : Symbol(__decorate, Decl(index.d.ts, 0, 0))
4+
>args : Symbol(args, Decl(index.d.ts, 0, 35))
5+
6+
=== /node_modules/tslib/index.d.mts ===
7+
8+
export * from "./index.js";
9+
10+
=== /index.mts ===
11+
declare var decorator: any;
12+
>decorator : Symbol(decorator, Decl(index.mts, 0, 11))
13+
14+
@decorator
15+
>decorator : Symbol(decorator, Decl(index.mts, 0, 11))
16+
17+
export class Foo {}
18+
>Foo : Symbol(Foo, Decl(index.mts, 0, 27))
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== /node_modules/tslib/index.d.ts ===
2+
export declare function __decorate(...args: any[]): any;
3+
>__decorate : (...args: any[]) => any
4+
>args : any[]
5+
6+
=== /node_modules/tslib/index.d.mts ===
7+
8+
export * from "./index.js";
9+
10+
=== /index.mts ===
11+
declare var decorator: any;
12+
>decorator : any
13+
14+
@decorator
15+
>decorator : any
16+
17+
export class Foo {}
18+
>Foo : Foo
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// @module: nodenext
2+
// @experimentalDecorators: true
3+
// @importHelpers: true
4+
5+
// @Filename: /node_modules/tslib/index.d.ts
6+
export declare function __decorate(...args: any[]): any;
7+
8+
// @Filename: /node_modules/tslib/index.d.mts
9+
export * from "./index.js";
10+
11+
// @Filename: /node_modules/tslib/package.json
12+
{
13+
"name": "tslib",
14+
"version": "1.0.0",
15+
"types": "index.d.ts",
16+
"exports": {
17+
".": {
18+
"types": {
19+
"import": "./index.d.mts",
20+
"default": "./index.d.ts"
21+
}
22+
}
23+
}
24+
}
25+
26+
// @Filename: /index.mts
27+
declare var decorator: any;
28+
@decorator
29+
export class Foo {}

0 commit comments

Comments
 (0)