Resolve tslib re-exports before checking arity (#54450)

This commit is contained in:
Andrew Branch 2023-05-30 13:47:06 -07:00 committed by GitHub
parent 63a210bd1d
commit fec0bd3275
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 241 additions and 1 deletions

View File

@ -47042,7 +47042,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (requestedExternalEmitHelperNames.has(name)) continue;
requestedExternalEmitHelperNames.add(name);
const symbol = getSymbol(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), SymbolFlags.Value);
const symbol = resolveSymbol(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);
}

View File

@ -0,0 +1,56 @@
//// [tests/cases/compiler/tslibReExportHelpers2.ts] ////
//// [index.d.ts]
export declare function __classPrivateFieldGet<T extends object, V>(
receiver: T,
state: { has(o: T): boolean, get(o: T): V | undefined },
kind?: "f"
): V;
export declare function __classPrivateFieldGet<T extends new (...args: any[]) => unknown, V>(
receiver: T,
state: T,
kind: "f",
f: { value: V }
): V;
//// [index.d.mts]
export { __classPrivateFieldGet } 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]
export class Foo {
constructor() {
console.log(Foo.#test());
}
static #test() {
return 'success';
}
}
//// [index.mjs]
var _a, _Foo_test;
import { __classPrivateFieldGet } from "tslib";
export class Foo {
constructor() {
console.log(__classPrivateFieldGet(Foo, _a, "m", _Foo_test).call(Foo));
}
}
_a = Foo, _Foo_test = function _Foo_test() {
return 'success';
};

View File

@ -0,0 +1,75 @@
=== /node_modules/tslib/index.d.ts ===
export declare function __classPrivateFieldGet<T extends object, V>(
>__classPrivateFieldGet : Symbol(__classPrivateFieldGet, Decl(index.d.ts, 0, 0), Decl(index.d.ts, 4, 5))
>T : Symbol(T, Decl(index.d.ts, 0, 47))
>V : Symbol(V, Decl(index.d.ts, 0, 64))
receiver: T,
>receiver : Symbol(receiver, Decl(index.d.ts, 0, 68))
>T : Symbol(T, Decl(index.d.ts, 0, 47))
state: { has(o: T): boolean, get(o: T): V | undefined },
>state : Symbol(state, Decl(index.d.ts, 1, 14))
>has : Symbol(has, Decl(index.d.ts, 2, 10))
>o : Symbol(o, Decl(index.d.ts, 2, 15))
>T : Symbol(T, Decl(index.d.ts, 0, 47))
>get : Symbol(get, Decl(index.d.ts, 2, 30))
>o : Symbol(o, Decl(index.d.ts, 2, 35))
>T : Symbol(T, Decl(index.d.ts, 0, 47))
>V : Symbol(V, Decl(index.d.ts, 0, 64))
kind?: "f"
>kind : Symbol(kind, Decl(index.d.ts, 2, 58))
): V;
>V : Symbol(V, Decl(index.d.ts, 0, 64))
export declare function __classPrivateFieldGet<T extends new (...args: any[]) => unknown, V>(
>__classPrivateFieldGet : Symbol(__classPrivateFieldGet, Decl(index.d.ts, 0, 0), Decl(index.d.ts, 4, 5))
>T : Symbol(T, Decl(index.d.ts, 5, 47))
>args : Symbol(args, Decl(index.d.ts, 5, 62))
>V : Symbol(V, Decl(index.d.ts, 5, 89))
receiver: T,
>receiver : Symbol(receiver, Decl(index.d.ts, 5, 93))
>T : Symbol(T, Decl(index.d.ts, 5, 47))
state: T,
>state : Symbol(state, Decl(index.d.ts, 6, 14))
>T : Symbol(T, Decl(index.d.ts, 5, 47))
kind: "f",
>kind : Symbol(kind, Decl(index.d.ts, 7, 11))
f: { value: V }
>f : Symbol(f, Decl(index.d.ts, 8, 12))
>value : Symbol(value, Decl(index.d.ts, 9, 6))
>V : Symbol(V, Decl(index.d.ts, 5, 89))
): V;
>V : Symbol(V, Decl(index.d.ts, 5, 89))
=== /node_modules/tslib/index.d.mts ===
export { __classPrivateFieldGet } from "./index.js";
>__classPrivateFieldGet : Symbol(__classPrivateFieldGet, Decl(index.d.mts, 0, 8))
=== /index.mts ===
export class Foo {
>Foo : Symbol(Foo, Decl(index.mts, 0, 0))
constructor() {
console.log(Foo.#test());
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>Foo.#test : Symbol(Foo.#test, Decl(index.mts, 3, 3))
>Foo : Symbol(Foo, Decl(index.mts, 0, 0))
}
static #test() {
>#test : Symbol(Foo.#test, Decl(index.mts, 3, 3))
return 'success';
}
}

View File

@ -0,0 +1,64 @@
=== /node_modules/tslib/index.d.ts ===
export declare function __classPrivateFieldGet<T extends object, V>(
>__classPrivateFieldGet : { <T extends object, V>(receiver: T, state: { has(o: T): boolean; get(o: T): V | undefined; }, kind?: "f"): V; <T extends new (...args: any[]) => unknown, V>(receiver: T, state: T, kind: "f", f: { value: V; }): V; }
receiver: T,
>receiver : T
state: { has(o: T): boolean, get(o: T): V | undefined },
>state : { has(o: T): boolean; get(o: T): V | undefined; }
>has : (o: T) => boolean
>o : T
>get : (o: T) => V | undefined
>o : T
kind?: "f"
>kind : "f"
): V;
export declare function __classPrivateFieldGet<T extends new (...args: any[]) => unknown, V>(
>__classPrivateFieldGet : { <T extends object, V>(receiver: T, state: { has(o: T): boolean; get(o: T): V; }, kind?: "f"): V; <T extends new (...args: any[]) => unknown, V>(receiver: T, state: T, kind: "f", f: { value: V;}): V; }
>args : any[]
receiver: T,
>receiver : T
state: T,
>state : T
kind: "f",
>kind : "f"
f: { value: V }
>f : { value: V; }
>value : V
): V;
=== /node_modules/tslib/index.d.mts ===
export { __classPrivateFieldGet } from "./index.js";
>__classPrivateFieldGet : { <T extends object, V>(receiver: T, state: { has(o: T): boolean; get(o: T): V; }, kind?: "f"): V; <T extends new (...args: any[]) => unknown, V>(receiver: T, state: T, kind: "f", f: { value: V; }): V; }
=== /index.mts ===
export class Foo {
>Foo : Foo
constructor() {
console.log(Foo.#test());
>console.log(Foo.#test()) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>Foo.#test() : string
>Foo.#test : () => string
>Foo : typeof Foo
}
static #test() {
>#test : () => string
return 'success';
>'success' : "success"
}
}

View File

@ -0,0 +1,45 @@
// @module: nodenext
// @importHelpers: true
// @target: es2021
// @Filename: /node_modules/tslib/index.d.ts
export declare function __classPrivateFieldGet<T extends object, V>(
receiver: T,
state: { has(o: T): boolean, get(o: T): V | undefined },
kind?: "f"
): V;
export declare function __classPrivateFieldGet<T extends new (...args: any[]) => unknown, V>(
receiver: T,
state: T,
kind: "f",
f: { value: V }
): V;
// @Filename: /node_modules/tslib/index.d.mts
export { __classPrivateFieldGet } 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
export class Foo {
constructor() {
console.log(Foo.#test());
}
static #test() {
return 'success';
}
}