From 85a28fa5a9567d3d16c3ca59ab402dd340044370 Mon Sep 17 00:00:00 2001 From: KAMRONBEK Date: Fri, 17 Jul 2026 00:22:55 +0500 Subject: [PATCH] Accept ArrayLike as the second argument of CallableFunction.apply Function.prototype.apply accepts any array-like as its second argument per the ECMAScript spec (CreateListFromArrayLike), so cases like String.fromCharCode.apply(null, uint8Array) and console.log.apply(null, arguments) work at runtime but were rejected under strictBindCallApply. Add an array-like apply overload to CallableFunction that routes real arrays/tuples back to the arity-checked tuple overload (Args extends readonly any[] ? A : Args), so strictBindCallApply's arity and element-type checks are fully preserved while non-array array-likes (arguments, typed arrays, DOM collections) are now accepted. Adds conformance fixture applyArrayLike.ts. Full test battery: 106377 passing, 0 failing. No JS emit baselines changed. Fixes #61835 --- src/lib/es5.d.ts | 10 + .../reference/applyArrayLike.errors.txt | 91 ++++++++ tests/baselines/reference/applyArrayLike.js | 53 +++++ .../reference/applyArrayLike.symbols | 103 +++++++++ .../baselines/reference/applyArrayLike.types | 206 ++++++++++++++++++ ...rgumentsReferenceInFunction1_Js.errors.txt | 5 +- .../argumentsReferenceInFunction1_Js.symbols | 4 +- .../argumentsReferenceInFunction1_Js.types | 8 +- ...unctionCapturesArguments_es2017.errors.txt | 16 +- ...owFunctionCapturesArguments_es2017.symbols | 4 +- ...rrowFunctionCapturesArguments_es2017.types | 8 +- ...resArguments_es5(target=es2015).errors.txt | 16 +- ...pturesArguments_es5(target=es2015).symbols | 4 +- ...CapturesArguments_es5(target=es2015).types | 8 +- ...pturesArguments_es5(target=es5).errors.txt | 18 +- ...nCapturesArguments_es5(target=es5).symbols | 4 +- ...ionCapturesArguments_es5(target=es5).types | 8 +- ...owFunctionCapturesArguments_es6.errors.txt | 16 +- ...ArrowFunctionCapturesArguments_es6.symbols | 4 +- ...ncArrowFunctionCapturesArguments_es6.types | 8 +- ...resArguments_es5(target=es2015).errors.txt | 16 +- ...pturesArguments_es5(target=es2015).symbols | 4 +- ...CapturesArguments_es5(target=es2015).types | 8 +- ...pturesArguments_es5(target=es5).errors.txt | 18 +- ...nCapturesArguments_es5(target=es5).symbols | 4 +- ...ionCapturesArguments_es5(target=es5).types | 8 +- .../coAndContraVariantInferences6.symbols | 4 +- .../coAndContraVariantInferences6.types | 8 +- ...mpletionsCommitCharactersAfterDot.baseline | 12 +- .../reference/declarationEmitPromise.symbols | 8 +- .../reference/declarationEmitPromise.types | 16 +- .../emitSkipsThisWithRestParameter.errors.txt | 18 +- .../emitSkipsThisWithRestParameter.symbols | 4 +- .../emitSkipsThisWithRestParameter.types | 8 +- .../esDecorators-contextualTypes.2.symbols | 4 +- .../esDecorators-contextualTypes.2.types | 8 +- .../baselines/reference/functionType.symbols | 4 +- tests/baselines/reference/functionType.types | 8 +- ...ameterReassignmentIIFEAnnotated.errors.txt | 7 +- ...ParameterReassignmentIIFEAnnotated.symbols | 4 +- ...noParameterReassignmentIIFEAnnotated.types | 8 +- .../noParameterReassignmentJSIIFE.errors.txt | 14 -- .../noParameterReassignmentJSIIFE.symbols | 4 +- .../noParameterReassignmentJSIIFE.types | 9 +- ...llSignatureAppearsToBeFunctionType.symbols | 8 +- ...CallSignatureAppearsToBeFunctionType.types | 16 +- .../reference/strictBindCallApply1.errors.txt | 108 +++++++-- .../reference/strictBindCallApply1.symbols | 36 +-- .../reference/strictBindCallApply1.types | 72 +++--- .../truthinessCallExpressionCoercion2.symbols | 4 +- .../truthinessCallExpressionCoercion2.types | 8 +- ...ctEmitSpreadAttribute(target=es2018).types | 2 +- .../conformance/functions/applyArrayLike.ts | 35 +++ 53 files changed, 855 insertions(+), 234 deletions(-) create mode 100644 tests/baselines/reference/applyArrayLike.errors.txt create mode 100644 tests/baselines/reference/applyArrayLike.js create mode 100644 tests/baselines/reference/applyArrayLike.symbols create mode 100644 tests/baselines/reference/applyArrayLike.types delete mode 100644 tests/baselines/reference/noParameterReassignmentJSIIFE.errors.txt create mode 100644 tests/cases/conformance/functions/applyArrayLike.ts diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 673ac55e47612..7366d35ff0159 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -324,6 +324,16 @@ interface CallableFunction extends Function { */ apply(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; + /** + * Calls the function with the specified object as the this value and the elements of the specified + * array-like object as the arguments. Real arrays and tuples are matched by the overload above, which + * checks their arity against the parameter list; this overload additionally accepts non-array + * array-likes (e.g. `arguments`, typed arrays, DOM collections) as permitted by the ECMAScript spec. + * @param thisArg The object to be used as the this object. + * @param args An array-like of argument values to be passed to the function. + */ + apply>(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; + /** * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. * @param thisArg The object to be used as the this object. diff --git a/tests/baselines/reference/applyArrayLike.errors.txt b/tests/baselines/reference/applyArrayLike.errors.txt new file mode 100644 index 0000000000000..3e5b0fd09a95e --- /dev/null +++ b/tests/baselines/reference/applyArrayLike.errors.txt @@ -0,0 +1,91 @@ +applyArrayLike.ts(25,34): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. + Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. + Source has 1 element(s) but target requires 2. + Overload 2 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. + Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. + Source has 1 element(s) but target requires 2. +applyArrayLike.ts(26,39): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. + Type 'number' is not assignable to type 'string'. + Overload 2 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. + Type 'number' is not assignable to type 'string'. +applyArrayLike.ts(27,34): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. + Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. + Source has 3 element(s) but target allows only 2. + Overload 2 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. + Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. + Source has 3 element(s) but target allows only 2. +applyArrayLike.ts(31,45): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: null, ...args: number[]) => string, thisArg: null, args: number[]): string', gave the following error. + Argument of type 'ArrayLike' is not assignable to parameter of type 'number[]'. + Type 'ArrayLike' is missing the following properties from type 'number[]': pop, push, concat, join, and 24 more. + Overload 2 of 3, '(this: (this: null, ...args: number[]) => string, thisArg: null, args: ArrayLike): string', gave the following error. + Argument of type 'ArrayLike' is not assignable to parameter of type 'ArrayLike'. + Type 'string' is not assignable to type 'number'. + + +==== applyArrayLike.ts (4 errors) ==== + // Repro for #61835: Function.prototype.apply accepts an array-like second argument + // per the ECMAScript spec (CreateListFromArrayLike), so CallableFunction.apply must + // accept ArrayLike, not just T[]. These cases work at runtime but previously errored. + + // --- Array-likes that should now be accepted --- + + declare const u8: Uint8Array; + const s1: string = String.fromCharCode.apply(null, u8); // Ok (Uint8Array is ArrayLike) + + const forwardArguments: (...args: unknown[]) => void = function () { + console.log.apply(null, arguments); // Ok (IArguments is array-like) + }; + forwardArguments(1, 2, 3); + + declare function variadic(...xs: number[]): void; + declare const arrayLikeNumbers: ArrayLike; + variadic.apply(undefined, arrayLikeNumbers); // Ok + + // A plain array/tuple still works via the arity-checked overload. + declare function foo(a: number, b: string): string; + const a00 = foo.apply(undefined, [10, "hello"]); // Ok + + // --- Regression guards: strictBindCallApply arity/element checks must be preserved --- + + const a01 = foo.apply(undefined, [10]); // Error: too few elements + ~~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. +!!! error TS2769: Source has 1 element(s) but target requires 2. +!!! error TS2769: Overload 2 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. +!!! error TS2769: Source has 1 element(s) but target requires 2. + const a02 = foo.apply(undefined, [10, 20]); // Error: wrong element type + ~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Type 'number' is not assignable to type 'string'. +!!! error TS2769: Overload 2 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Type 'number' is not assignable to type 'string'. + const a03 = foo.apply(undefined, [10, "hello", 30]); // Error: too many elements + ~~~~~~~~~~~~~~~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. +!!! error TS2769: Source has 3 element(s) but target allows only 2. +!!! error TS2769: Overload 2 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. +!!! error TS2769: Source has 3 element(s) but target allows only 2. + + // An array-like of the wrong element type must still be rejected. + declare const arrayLikeStrings: ArrayLike; + const bad = String.fromCharCode.apply(null, arrayLikeStrings); // Error: string is not number + ~~~~~~~~~~~~~~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: null, ...args: number[]) => string, thisArg: null, args: number[]): string', gave the following error. +!!! error TS2769: Argument of type 'ArrayLike' is not assignable to parameter of type 'number[]'. +!!! error TS2769: Type 'ArrayLike' is missing the following properties from type 'number[]': pop, push, concat, join, and 24 more. +!!! error TS2769: Overload 2 of 3, '(this: (this: null, ...args: number[]) => string, thisArg: null, args: ArrayLike): string', gave the following error. +!!! error TS2769: Argument of type 'ArrayLike' is not assignable to parameter of type 'ArrayLike'. +!!! error TS2769: Type 'string' is not assignable to type 'number'. + \ No newline at end of file diff --git a/tests/baselines/reference/applyArrayLike.js b/tests/baselines/reference/applyArrayLike.js new file mode 100644 index 0000000000000..abe56ce403c22 --- /dev/null +++ b/tests/baselines/reference/applyArrayLike.js @@ -0,0 +1,53 @@ +//// [tests/cases/conformance/functions/applyArrayLike.ts] //// + +//// [applyArrayLike.ts] +// Repro for #61835: Function.prototype.apply accepts an array-like second argument +// per the ECMAScript spec (CreateListFromArrayLike), so CallableFunction.apply must +// accept ArrayLike, not just T[]. These cases work at runtime but previously errored. + +// --- Array-likes that should now be accepted --- + +declare const u8: Uint8Array; +const s1: string = String.fromCharCode.apply(null, u8); // Ok (Uint8Array is ArrayLike) + +const forwardArguments: (...args: unknown[]) => void = function () { + console.log.apply(null, arguments); // Ok (IArguments is array-like) +}; +forwardArguments(1, 2, 3); + +declare function variadic(...xs: number[]): void; +declare const arrayLikeNumbers: ArrayLike; +variadic.apply(undefined, arrayLikeNumbers); // Ok + +// A plain array/tuple still works via the arity-checked overload. +declare function foo(a: number, b: string): string; +const a00 = foo.apply(undefined, [10, "hello"]); // Ok + +// --- Regression guards: strictBindCallApply arity/element checks must be preserved --- + +const a01 = foo.apply(undefined, [10]); // Error: too few elements +const a02 = foo.apply(undefined, [10, 20]); // Error: wrong element type +const a03 = foo.apply(undefined, [10, "hello", 30]); // Error: too many elements + +// An array-like of the wrong element type must still be rejected. +declare const arrayLikeStrings: ArrayLike; +const bad = String.fromCharCode.apply(null, arrayLikeStrings); // Error: string is not number + + +//// [applyArrayLike.js] +"use strict"; +// Repro for #61835: Function.prototype.apply accepts an array-like second argument +// per the ECMAScript spec (CreateListFromArrayLike), so CallableFunction.apply must +// accept ArrayLike, not just T[]. These cases work at runtime but previously errored. +const s1 = String.fromCharCode.apply(null, u8); // Ok (Uint8Array is ArrayLike) +const forwardArguments = function () { + console.log.apply(null, arguments); // Ok (IArguments is array-like) +}; +forwardArguments(1, 2, 3); +variadic.apply(undefined, arrayLikeNumbers); // Ok +const a00 = foo.apply(undefined, [10, "hello"]); // Ok +// --- Regression guards: strictBindCallApply arity/element checks must be preserved --- +const a01 = foo.apply(undefined, [10]); // Error: too few elements +const a02 = foo.apply(undefined, [10, 20]); // Error: wrong element type +const a03 = foo.apply(undefined, [10, "hello", 30]); // Error: too many elements +const bad = String.fromCharCode.apply(null, arrayLikeStrings); // Error: string is not number diff --git a/tests/baselines/reference/applyArrayLike.symbols b/tests/baselines/reference/applyArrayLike.symbols new file mode 100644 index 0000000000000..fac88e2834fca --- /dev/null +++ b/tests/baselines/reference/applyArrayLike.symbols @@ -0,0 +1,103 @@ +//// [tests/cases/conformance/functions/applyArrayLike.ts] //// + +=== applyArrayLike.ts === +// Repro for #61835: Function.prototype.apply accepts an array-like second argument +// per the ECMAScript spec (CreateListFromArrayLike), so CallableFunction.apply must +// accept ArrayLike, not just T[]. These cases work at runtime but previously errored. + +// --- Array-likes that should now be accepted --- + +declare const u8: Uint8Array; +>u8 : Symbol(u8, Decl(applyArrayLike.ts, 6, 13)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +const s1: string = String.fromCharCode.apply(null, u8); // Ok (Uint8Array is ArrayLike) +>s1 : Symbol(s1, Decl(applyArrayLike.ts, 7, 5)) +>String.fromCharCode.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>String.fromCharCode : Symbol(StringConstructor.fromCharCode, Decl(lib.es5.d.ts, --, --)) +>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 1 more) +>fromCharCode : Symbol(StringConstructor.fromCharCode, Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>u8 : Symbol(u8, Decl(applyArrayLike.ts, 6, 13)) + +const forwardArguments: (...args: unknown[]) => void = function () { +>forwardArguments : Symbol(forwardArguments, Decl(applyArrayLike.ts, 9, 5)) +>args : Symbol(args, Decl(applyArrayLike.ts, 9, 25)) + + console.log.apply(null, arguments); // Ok (IArguments is array-like) +>console.log.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>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, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arguments : Symbol(arguments) + +}; +forwardArguments(1, 2, 3); +>forwardArguments : Symbol(forwardArguments, Decl(applyArrayLike.ts, 9, 5)) + +declare function variadic(...xs: number[]): void; +>variadic : Symbol(variadic, Decl(applyArrayLike.ts, 12, 26)) +>xs : Symbol(xs, Decl(applyArrayLike.ts, 14, 26)) + +declare const arrayLikeNumbers: ArrayLike; +>arrayLikeNumbers : Symbol(arrayLikeNumbers, Decl(applyArrayLike.ts, 15, 13)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.es5.d.ts, --, --)) + +variadic.apply(undefined, arrayLikeNumbers); // Ok +>variadic.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>variadic : Symbol(variadic, Decl(applyArrayLike.ts, 12, 26)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) +>arrayLikeNumbers : Symbol(arrayLikeNumbers, Decl(applyArrayLike.ts, 15, 13)) + +// A plain array/tuple still works via the arity-checked overload. +declare function foo(a: number, b: string): string; +>foo : Symbol(foo, Decl(applyArrayLike.ts, 16, 44)) +>a : Symbol(a, Decl(applyArrayLike.ts, 19, 21)) +>b : Symbol(b, Decl(applyArrayLike.ts, 19, 31)) + +const a00 = foo.apply(undefined, [10, "hello"]); // Ok +>a00 : Symbol(a00, Decl(applyArrayLike.ts, 20, 5)) +>foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>foo : Symbol(foo, Decl(applyArrayLike.ts, 16, 44)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +// --- Regression guards: strictBindCallApply arity/element checks must be preserved --- + +const a01 = foo.apply(undefined, [10]); // Error: too few elements +>a01 : Symbol(a01, Decl(applyArrayLike.ts, 24, 5)) +>foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>foo : Symbol(foo, Decl(applyArrayLike.ts, 16, 44)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const a02 = foo.apply(undefined, [10, 20]); // Error: wrong element type +>a02 : Symbol(a02, Decl(applyArrayLike.ts, 25, 5)) +>foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>foo : Symbol(foo, Decl(applyArrayLike.ts, 16, 44)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const a03 = foo.apply(undefined, [10, "hello", 30]); // Error: too many elements +>a03 : Symbol(a03, Decl(applyArrayLike.ts, 26, 5)) +>foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>foo : Symbol(foo, Decl(applyArrayLike.ts, 16, 44)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +// An array-like of the wrong element type must still be rejected. +declare const arrayLikeStrings: ArrayLike; +>arrayLikeStrings : Symbol(arrayLikeStrings, Decl(applyArrayLike.ts, 29, 13)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.es5.d.ts, --, --)) + +const bad = String.fromCharCode.apply(null, arrayLikeStrings); // Error: string is not number +>bad : Symbol(bad, Decl(applyArrayLike.ts, 30, 5)) +>String.fromCharCode.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>String.fromCharCode : Symbol(StringConstructor.fromCharCode, Decl(lib.es5.d.ts, --, --)) +>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 1 more) +>fromCharCode : Symbol(StringConstructor.fromCharCode, Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arrayLikeStrings : Symbol(arrayLikeStrings, Decl(applyArrayLike.ts, 29, 13)) + diff --git a/tests/baselines/reference/applyArrayLike.types b/tests/baselines/reference/applyArrayLike.types new file mode 100644 index 0000000000000..424e873304422 --- /dev/null +++ b/tests/baselines/reference/applyArrayLike.types @@ -0,0 +1,206 @@ +//// [tests/cases/conformance/functions/applyArrayLike.ts] //// + +=== applyArrayLike.ts === +// Repro for #61835: Function.prototype.apply accepts an array-like second argument +// per the ECMAScript spec (CreateListFromArrayLike), so CallableFunction.apply must +// accept ArrayLike, not just T[]. These cases work at runtime but previously errored. + +// --- Array-likes that should now be accepted --- + +declare const u8: Uint8Array; +>u8 : Uint8Array +> : ^^^^^^^^^^^^^^^^^^^^^^^ + +const s1: string = String.fromCharCode.apply(null, u8); // Ok (Uint8Array is ArrayLike) +>s1 : string +> : ^^^^^^ +>String.fromCharCode.apply(null, u8) : string +> : ^^^^^^ +>String.fromCharCode.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>String.fromCharCode : (...codes: number[]) => string +> : ^^^^ ^^ ^^^^^ +>String : StringConstructor +> : ^^^^^^^^^^^^^^^^^ +>fromCharCode : (...codes: number[]) => string +> : ^^^^ ^^ ^^^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>u8 : Uint8Array +> : ^^^^^^^^^^^^^^^^^^^^^^^ + +const forwardArguments: (...args: unknown[]) => void = function () { +>forwardArguments : (...args: unknown[]) => void +> : ^^^^ ^^ ^^^^^ +>args : unknown[] +> : ^^^^^^^^^ +>function () { console.log.apply(null, arguments); // Ok (IArguments is array-like)} : () => void +> : ^^^^^^^^^^ + + console.log.apply(null, arguments); // Ok (IArguments is array-like) +>console.log.apply(null, arguments) : void +> : ^^^^ +>console.log.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>arguments : IArguments +> : ^^^^^^^^^^ + +}; +forwardArguments(1, 2, 3); +>forwardArguments(1, 2, 3) : void +> : ^^^^ +>forwardArguments : (...args: unknown[]) => void +> : ^^^^ ^^ ^^^^^ +>1 : 1 +> : ^ +>2 : 2 +> : ^ +>3 : 3 +> : ^ + +declare function variadic(...xs: number[]): void; +>variadic : (...xs: number[]) => void +> : ^^^^ ^^ ^^^^^ +>xs : number[] +> : ^^^^^^^^ + +declare const arrayLikeNumbers: ArrayLike; +>arrayLikeNumbers : ArrayLike +> : ^^^^^^^^^^^^^^^^^ + +variadic.apply(undefined, arrayLikeNumbers); // Ok +>variadic.apply(undefined, arrayLikeNumbers) : void +> : ^^^^ +>variadic.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>variadic : (...xs: number[]) => void +> : ^^^^ ^^ ^^^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>undefined : undefined +> : ^^^^^^^^^ +>arrayLikeNumbers : ArrayLike +> : ^^^^^^^^^^^^^^^^^ + +// A plain array/tuple still works via the arity-checked overload. +declare function foo(a: number, b: string): string; +>foo : (a: number, b: string) => string +> : ^ ^^ ^^ ^^ ^^^^^ +>a : number +> : ^^^^^^ +>b : string +> : ^^^^^^ + +const a00 = foo.apply(undefined, [10, "hello"]); // Ok +>a00 : string +> : ^^^^^^ +>foo.apply(undefined, [10, "hello"]) : string +> : ^^^^^^ +>foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>foo : (a: number, b: string) => string +> : ^ ^^ ^^ ^^ ^^^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>undefined : undefined +> : ^^^^^^^^^ +>[10, "hello"] : [number, string] +> : ^^^^^^^^^^^^^^^^ +>10 : 10 +> : ^^ +>"hello" : "hello" +> : ^^^^^^^ + +// --- Regression guards: strictBindCallApply arity/element checks must be preserved --- + +const a01 = foo.apply(undefined, [10]); // Error: too few elements +>a01 : string +> : ^^^^^^ +>foo.apply(undefined, [10]) : string +> : ^^^^^^ +>foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>foo : (a: number, b: string) => string +> : ^ ^^ ^^ ^^ ^^^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>undefined : undefined +> : ^^^^^^^^^ +>[10] : [number] +> : ^^^^^^^^ +>10 : 10 +> : ^^ + +const a02 = foo.apply(undefined, [10, 20]); // Error: wrong element type +>a02 : string +> : ^^^^^^ +>foo.apply(undefined, [10, 20]) : string +> : ^^^^^^ +>foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>foo : (a: number, b: string) => string +> : ^ ^^ ^^ ^^ ^^^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>undefined : undefined +> : ^^^^^^^^^ +>[10, 20] : [number, number] +> : ^^^^^^^^^^^^^^^^ +>10 : 10 +> : ^^ +>20 : 20 +> : ^^ + +const a03 = foo.apply(undefined, [10, "hello", 30]); // Error: too many elements +>a03 : string +> : ^^^^^^ +>foo.apply(undefined, [10, "hello", 30]) : string +> : ^^^^^^ +>foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>foo : (a: number, b: string) => string +> : ^ ^^ ^^ ^^ ^^^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>undefined : undefined +> : ^^^^^^^^^ +>[10, "hello", 30] : [number, string, number] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>10 : 10 +> : ^^ +>"hello" : "hello" +> : ^^^^^^^ +>30 : 30 +> : ^^ + +// An array-like of the wrong element type must still be rejected. +declare const arrayLikeStrings: ArrayLike; +>arrayLikeStrings : ArrayLike +> : ^^^^^^^^^^^^^^^^^ + +const bad = String.fromCharCode.apply(null, arrayLikeStrings); // Error: string is not number +>bad : string +> : ^^^^^^ +>String.fromCharCode.apply(null, arrayLikeStrings) : string +> : ^^^^^^ +>String.fromCharCode.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>String.fromCharCode : (...codes: number[]) => string +> : ^^^^ ^^ ^^^^^ +>String : StringConstructor +> : ^^^^^^^^^^^^^^^^^ +>fromCharCode : (...codes: number[]) => string +> : ^^^^ ^^ ^^^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>arrayLikeStrings : ArrayLike +> : ^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/argumentsReferenceInFunction1_Js.errors.txt b/tests/baselines/reference/argumentsReferenceInFunction1_Js.errors.txt index 9d55aafa33e31..aeb08d38df67b 100644 --- a/tests/baselines/reference/argumentsReferenceInFunction1_Js.errors.txt +++ b/tests/baselines/reference/argumentsReferenceInFunction1_Js.errors.txt @@ -1,8 +1,7 @@ index.js(1,25): error TS7006: Parameter 'f' implicitly has an 'any' type. -index.js(13,29): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[f?: any, ...any[]]'. -==== index.js (2 errors) ==== +==== index.js (1 errors) ==== const format = function(f) { ~ !!! error TS7006: Parameter 'f' implicitly has an 'any' type. @@ -18,7 +17,5 @@ index.js(13,29): error TS2345: Argument of type 'IArguments' is not assignable t const debuglog = function() { return format.apply(null, arguments); - ~~~~~~~~~ -!!! error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[f?: any, ...any[]]'. }; \ No newline at end of file diff --git a/tests/baselines/reference/argumentsReferenceInFunction1_Js.symbols b/tests/baselines/reference/argumentsReferenceInFunction1_Js.symbols index 548541a72ad26..733fac0b25612 100644 --- a/tests/baselines/reference/argumentsReferenceInFunction1_Js.symbols +++ b/tests/baselines/reference/argumentsReferenceInFunction1_Js.symbols @@ -44,9 +44,9 @@ const debuglog = function() { >debuglog : Symbol(debuglog, Decl(index.js, 11, 5)) return format.apply(null, arguments); ->format.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>format.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >format : Symbol(format, Decl(index.js, 0, 5)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arguments : Symbol(arguments) }; diff --git a/tests/baselines/reference/argumentsReferenceInFunction1_Js.types b/tests/baselines/reference/argumentsReferenceInFunction1_Js.types index 2d41b9e618782..aabf1a8813843 100644 --- a/tests/baselines/reference/argumentsReferenceInFunction1_Js.types +++ b/tests/baselines/reference/argumentsReferenceInFunction1_Js.types @@ -92,12 +92,12 @@ const debuglog = function() { return format.apply(null, arguments); >format.apply(null, arguments) : string > : ^^^^^^ ->format.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>format.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >format : (f: any, ...args: any[]) => string > : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >arguments : IArguments > : ^^^^^^^^^^ diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.errors.txt index 3860fe3e9cadc..45b4fa062ac2d 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.errors.txt +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.errors.txt @@ -1,4 +1,10 @@ -asyncArrowFunctionCapturesArguments_es2017.ts(4,52): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[]'. +asyncArrowFunctionCapturesArguments_es2017.ts(4,52): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: this) => void, thisArg: this, args: []): void', gave the following error. + Argument of type 'IArguments' is not assignable to parameter of type '[]'. + Overload 2 of 3, '(this: (this: this) => void, thisArg: this, args: ArrayLike): void', gave the following error. + Argument of type 'IArguments' is not assignable to parameter of type 'ArrayLike'. + 'number' index signatures are incompatible. + Type 'any' is not assignable to type 'never'. ==== asyncArrowFunctionCapturesArguments_es2017.ts (1 errors) ==== @@ -7,7 +13,13 @@ asyncArrowFunctionCapturesArguments_es2017.ts(4,52): error TS2345: Argument of t function other() {} var fn = async () => await other.apply(this, arguments); ~~~~~~~~~ -!!! error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[]'. +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: this) => void, thisArg: this, args: []): void', gave the following error. +!!! error TS2769: Argument of type 'IArguments' is not assignable to parameter of type '[]'. +!!! error TS2769: Overload 2 of 3, '(this: (this: this) => void, thisArg: this, args: ArrayLike): void', gave the following error. +!!! error TS2769: Argument of type 'IArguments' is not assignable to parameter of type 'ArrayLike'. +!!! error TS2769: 'number' index signatures are incompatible. +!!! error TS2769: Type 'any' is not assignable to type 'never'. } } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.symbols index d53e21fdeaede..232ab26ee1a45 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.symbols +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.symbols @@ -12,9 +12,9 @@ class C { var fn = async () => await other.apply(this, arguments); >fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 3, 9)) ->other.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>other.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 1, 13)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 0, 0)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.types b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.types index 1f6fbcf53c412..fb1feaa2b7206 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.types +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.types @@ -22,12 +22,12 @@ class C { > : ^^^^ >other.apply(this, arguments) : void > : ^^^^ ->other.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>other.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >other : () => void > : ^^^^^^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >this : this > : ^^^^ >arguments : IArguments diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es2015).errors.txt b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es2015).errors.txt index 408df1a7231b0..a21cfd39da1cb 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es2015).errors.txt +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es2015).errors.txt @@ -1,4 +1,10 @@ -asyncArrowFunctionCapturesArguments_es5.ts(4,52): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[]'. +asyncArrowFunctionCapturesArguments_es5.ts(4,52): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: this) => void, thisArg: this, args: []): void', gave the following error. + Argument of type 'IArguments' is not assignable to parameter of type '[]'. + Overload 2 of 3, '(this: (this: this) => void, thisArg: this, args: ArrayLike): void', gave the following error. + Argument of type 'IArguments' is not assignable to parameter of type 'ArrayLike'. + 'number' index signatures are incompatible. + Type 'any' is not assignable to type 'never'. ==== asyncArrowFunctionCapturesArguments_es5.ts (1 errors) ==== @@ -7,7 +13,13 @@ asyncArrowFunctionCapturesArguments_es5.ts(4,52): error TS2345: Argument of type function other() {} var fn = async () => await other.apply(this, arguments); ~~~~~~~~~ -!!! error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[]'. +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: this) => void, thisArg: this, args: []): void', gave the following error. +!!! error TS2769: Argument of type 'IArguments' is not assignable to parameter of type '[]'. +!!! error TS2769: Overload 2 of 3, '(this: (this: this) => void, thisArg: this, args: ArrayLike): void', gave the following error. +!!! error TS2769: Argument of type 'IArguments' is not assignable to parameter of type 'ArrayLike'. +!!! error TS2769: 'number' index signatures are incompatible. +!!! error TS2769: Type 'any' is not assignable to type 'never'. } } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es2015).symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es2015).symbols index c2a826e3ff498..bd8830ee24a55 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es2015).symbols +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es2015).symbols @@ -12,9 +12,9 @@ class C { var fn = async () => await other.apply(this, arguments); >fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es5.ts, 3, 9)) ->other.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>other.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es5.ts, 1, 13)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es5.ts, 0, 0)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es2015).types b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es2015).types index 8d83d4969a928..cfd3a3f4af185 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es2015).types +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es2015).types @@ -22,12 +22,12 @@ class C { > : ^^^^ >other.apply(this, arguments) : void > : ^^^^ ->other.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>other.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >other : () => void > : ^^^^^^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >this : this > : ^^^^ >arguments : IArguments diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es5).errors.txt b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es5).errors.txt index bce95f1bff9af..391a278d1ba18 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es5).errors.txt +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es5).errors.txt @@ -1,6 +1,12 @@ error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. -asyncArrowFunctionCapturesArguments_es5.ts(4,52): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[]'. asyncArrowFunctionCapturesArguments_es5.ts(4,52): error TS2496: The 'arguments' object cannot be referenced in an arrow function in ES5. Consider using a standard function expression. +asyncArrowFunctionCapturesArguments_es5.ts(4,52): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: this) => void, thisArg: this, args: []): void', gave the following error. + Argument of type 'IArguments' is not assignable to parameter of type '[]'. + Overload 2 of 3, '(this: (this: this) => void, thisArg: this, args: ArrayLike): void', gave the following error. + Argument of type 'IArguments' is not assignable to parameter of type 'ArrayLike'. + 'number' index signatures are incompatible. + Type 'any' is not assignable to type 'never'. !!! error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. @@ -10,9 +16,15 @@ asyncArrowFunctionCapturesArguments_es5.ts(4,52): error TS2496: The 'arguments' function other() {} var fn = async () => await other.apply(this, arguments); ~~~~~~~~~ -!!! error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[]'. - ~~~~~~~~~ !!! error TS2496: The 'arguments' object cannot be referenced in an arrow function in ES5. Consider using a standard function expression. + ~~~~~~~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: this) => void, thisArg: this, args: []): void', gave the following error. +!!! error TS2769: Argument of type 'IArguments' is not assignable to parameter of type '[]'. +!!! error TS2769: Overload 2 of 3, '(this: (this: this) => void, thisArg: this, args: ArrayLike): void', gave the following error. +!!! error TS2769: Argument of type 'IArguments' is not assignable to parameter of type 'ArrayLike'. +!!! error TS2769: 'number' index signatures are incompatible. +!!! error TS2769: Type 'any' is not assignable to type 'never'. } } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es5).symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es5).symbols index c2a826e3ff498..bd8830ee24a55 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es5).symbols +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es5).symbols @@ -12,9 +12,9 @@ class C { var fn = async () => await other.apply(this, arguments); >fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es5.ts, 3, 9)) ->other.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>other.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es5.ts, 1, 13)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es5.ts, 0, 0)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es5).types b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es5).types index 8d83d4969a928..cfd3a3f4af185 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es5).types +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5(target=es5).types @@ -22,12 +22,12 @@ class C { > : ^^^^ >other.apply(this, arguments) : void > : ^^^^ ->other.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>other.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >other : () => void > : ^^^^^^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >this : this > : ^^^^ >arguments : IArguments diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt index 23917e19b0c2b..49e0d4d4018dd 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.errors.txt @@ -1,4 +1,10 @@ -asyncArrowFunctionCapturesArguments_es6.ts(4,52): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[]'. +asyncArrowFunctionCapturesArguments_es6.ts(4,52): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: this) => void, thisArg: this, args: []): void', gave the following error. + Argument of type 'IArguments' is not assignable to parameter of type '[]'. + Overload 2 of 3, '(this: (this: this) => void, thisArg: this, args: ArrayLike): void', gave the following error. + Argument of type 'IArguments' is not assignable to parameter of type 'ArrayLike'. + 'number' index signatures are incompatible. + Type 'any' is not assignable to type 'never'. ==== asyncArrowFunctionCapturesArguments_es6.ts (1 errors) ==== @@ -7,7 +13,13 @@ asyncArrowFunctionCapturesArguments_es6.ts(4,52): error TS2345: Argument of type function other() {} var fn = async () => await other.apply(this, arguments); ~~~~~~~~~ -!!! error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[]'. +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: this) => void, thisArg: this, args: []): void', gave the following error. +!!! error TS2769: Argument of type 'IArguments' is not assignable to parameter of type '[]'. +!!! error TS2769: Overload 2 of 3, '(this: (this: this) => void, thisArg: this, args: ArrayLike): void', gave the following error. +!!! error TS2769: Argument of type 'IArguments' is not assignable to parameter of type 'ArrayLike'. +!!! error TS2769: 'number' index signatures are incompatible. +!!! error TS2769: Type 'any' is not assignable to type 'never'. } } diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols index fbb0e710d5c2c..34e53c5dd84ae 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols @@ -12,9 +12,9 @@ class C { var fn = async () => await other.apply(this, arguments); >fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 3, 9)) ->other.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>other.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 1, 13)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 0, 0)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types index 2874f001bcbce..711d7b77f575b 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types @@ -22,12 +22,12 @@ class C { > : ^^^^ >other.apply(this, arguments) : void > : ^^^^ ->other.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>other.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >other : () => void > : ^^^^^^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >this : this > : ^^^^ >arguments : IArguments diff --git a/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es2015).errors.txt b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es2015).errors.txt index 6f4b7c10ffe0b..25f212c0caf8a 100644 --- a/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es2015).errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es2015).errors.txt @@ -1,5 +1,11 @@ asyncFunctionDeclarationCapturesArguments_es5.ts(5,30): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -asyncFunctionDeclarationCapturesArguments_es5.ts(5,36): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[]'. +asyncFunctionDeclarationCapturesArguments_es5.ts(5,36): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: any) => void, thisArg: any, args: []): void', gave the following error. + Argument of type 'IArguments' is not assignable to parameter of type '[]'. + Overload 2 of 3, '(this: (this: any) => void, thisArg: any, args: ArrayLike): void', gave the following error. + Argument of type 'IArguments' is not assignable to parameter of type 'ArrayLike'. + 'number' index signatures are incompatible. + Type 'any' is not assignable to type 'never'. ==== asyncFunctionDeclarationCapturesArguments_es5.ts (2 errors) ==== @@ -12,7 +18,13 @@ asyncFunctionDeclarationCapturesArguments_es5.ts(5,36): error TS2345: Argument o !!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. !!! related TS2738 asyncFunctionDeclarationCapturesArguments_es5.ts:4:22: An outer value of 'this' is shadowed by this container. ~~~~~~~~~ -!!! error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[]'. +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: any) => void, thisArg: any, args: []): void', gave the following error. +!!! error TS2769: Argument of type 'IArguments' is not assignable to parameter of type '[]'. +!!! error TS2769: Overload 2 of 3, '(this: (this: any) => void, thisArg: any, args: ArrayLike): void', gave the following error. +!!! error TS2769: Argument of type 'IArguments' is not assignable to parameter of type 'ArrayLike'. +!!! error TS2769: 'number' index signatures are incompatible. +!!! error TS2769: Type 'any' is not assignable to type 'never'. } } } diff --git a/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es2015).symbols b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es2015).symbols index a89d55af0189f..c8511bcc49bcb 100644 --- a/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es2015).symbols +++ b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es2015).symbols @@ -14,9 +14,9 @@ class C { >fn : Symbol(fn, Decl(asyncFunctionDeclarationCapturesArguments_es5.ts, 2, 25)) await other.apply(this, arguments); ->other.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>other.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >other : Symbol(other, Decl(asyncFunctionDeclarationCapturesArguments_es5.ts, 1, 13)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arguments : Symbol(arguments) } } diff --git a/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es2015).types b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es2015).types index 60b938fc15328..a462706157488 100644 --- a/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es2015).types +++ b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es2015).types @@ -22,12 +22,12 @@ class C { > : ^^^^ >other.apply(this, arguments) : void > : ^^^^ ->other.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>other.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >other : () => void > : ^^^^^^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >this : any > : ^^^ >arguments : IArguments diff --git a/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es5).errors.txt b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es5).errors.txt index 28c9431ab40df..83316b352bfa8 100644 --- a/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es5).errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es5).errors.txt @@ -1,7 +1,13 @@ error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. asyncFunctionDeclarationCapturesArguments_es5.ts(5,30): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -asyncFunctionDeclarationCapturesArguments_es5.ts(5,36): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[]'. asyncFunctionDeclarationCapturesArguments_es5.ts(5,36): error TS2522: The 'arguments' object cannot be referenced in an async function or method in ES5. Consider using a standard function or method. +asyncFunctionDeclarationCapturesArguments_es5.ts(5,36): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: any) => void, thisArg: any, args: []): void', gave the following error. + Argument of type 'IArguments' is not assignable to parameter of type '[]'. + Overload 2 of 3, '(this: (this: any) => void, thisArg: any, args: ArrayLike): void', gave the following error. + Argument of type 'IArguments' is not assignable to parameter of type 'ArrayLike'. + 'number' index signatures are incompatible. + Type 'any' is not assignable to type 'never'. !!! error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. @@ -15,9 +21,15 @@ asyncFunctionDeclarationCapturesArguments_es5.ts(5,36): error TS2522: The 'argum !!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. !!! related TS2738 asyncFunctionDeclarationCapturesArguments_es5.ts:4:22: An outer value of 'this' is shadowed by this container. ~~~~~~~~~ -!!! error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[]'. - ~~~~~~~~~ !!! error TS2522: The 'arguments' object cannot be referenced in an async function or method in ES5. Consider using a standard function or method. + ~~~~~~~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: any) => void, thisArg: any, args: []): void', gave the following error. +!!! error TS2769: Argument of type 'IArguments' is not assignable to parameter of type '[]'. +!!! error TS2769: Overload 2 of 3, '(this: (this: any) => void, thisArg: any, args: ArrayLike): void', gave the following error. +!!! error TS2769: Argument of type 'IArguments' is not assignable to parameter of type 'ArrayLike'. +!!! error TS2769: 'number' index signatures are incompatible. +!!! error TS2769: Type 'any' is not assignable to type 'never'. } } } diff --git a/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es5).symbols b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es5).symbols index a89d55af0189f..c8511bcc49bcb 100644 --- a/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es5).symbols +++ b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es5).symbols @@ -14,9 +14,9 @@ class C { >fn : Symbol(fn, Decl(asyncFunctionDeclarationCapturesArguments_es5.ts, 2, 25)) await other.apply(this, arguments); ->other.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>other.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >other : Symbol(other, Decl(asyncFunctionDeclarationCapturesArguments_es5.ts, 1, 13)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arguments : Symbol(arguments) } } diff --git a/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es5).types b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es5).types index 60b938fc15328..a462706157488 100644 --- a/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es5).types +++ b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5(target=es5).types @@ -22,12 +22,12 @@ class C { > : ^^^^ >other.apply(this, arguments) : void > : ^^^^ ->other.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>other.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >other : () => void > : ^^^^^^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >this : any > : ^^^ >arguments : IArguments diff --git a/tests/baselines/reference/coAndContraVariantInferences6.symbols b/tests/baselines/reference/coAndContraVariantInferences6.symbols index 4046a60430813..0614d292190a8 100644 --- a/tests/baselines/reference/coAndContraVariantInferences6.symbols +++ b/tests/baselines/reference/coAndContraVariantInferences6.symbols @@ -102,10 +102,10 @@ declare const stat: any; >stat : Symbol(stat, Decl(coAndContraVariantInferences6.ts, 36, 13)) [].push.apply(props, stat.properties); ->[].push.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>[].push.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >[].push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) >push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >props : Symbol(props, Decl(coAndContraVariantInferences6.ts, 35, 13)) >stat : Symbol(stat, Decl(coAndContraVariantInferences6.ts, 36, 13)) diff --git a/tests/baselines/reference/coAndContraVariantInferences6.types b/tests/baselines/reference/coAndContraVariantInferences6.types index 45f78449069d0..05c386aaec33e 100644 --- a/tests/baselines/reference/coAndContraVariantInferences6.types +++ b/tests/baselines/reference/coAndContraVariantInferences6.types @@ -92,16 +92,16 @@ declare const stat: any; [].push.apply(props, stat.properties); >[].push.apply(props, stat.properties) : number > : ^^^^^^ ->[].push.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>[].push.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >[].push : (...items: never[]) => number > : ^^^^ ^^^^^^^^^^^^^^ >[] : never[] > : ^^^^^^^ >push : (...items: never[]) => number > : ^^^^ ^^^^^^^^^^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >props : any[] > : ^^^^^ >stat.properties : any diff --git a/tests/baselines/reference/completionsCommitCharactersAfterDot.baseline b/tests/baselines/reference/completionsCommitCharactersAfterDot.baseline index 3e35e33ce2e79..0a931187348a9 100644 --- a/tests/baselines/reference/completionsCommitCharactersAfterDot.baseline +++ b/tests/baselines/reference/completionsCommitCharactersAfterDot.baseline @@ -26,7 +26,7 @@ // const w = obj4?. // ^ // | ---------------------------------------------------------------------- -// | (method) CallableFunction.apply(this: (this: T) => R, thisArg: T): R (+1 overload) +// | (method) CallableFunction.apply(this: (this: T) => R, thisArg: T): R (+2 overloads) // | (property) Function.arguments: any // | (method) CallableFunction.bind(this: T, thisArg: ThisParameterType): OmitThisParameter (+1 overload) // | (method) CallableFunction.call(this: (this: T, ...args: A) => R, thisArg: T, ...args: A): R @@ -39,7 +39,7 @@ // const a = obj5?. // ^ // | ---------------------------------------------------------------------- -// | (method) CallableFunction.apply(this: (this: T) => R, thisArg: T): R (+1 overload) +// | (method) CallableFunction.apply(this: (this: T) => R, thisArg: T): R (+2 overloads) // | (property) Function.arguments: any // | (method) CallableFunction.bind(this: T, thisArg: ThisParameterType): OmitThisParameter (+1 overload) // | (method) CallableFunction.call(this: (this: T, ...args: A) => R, thisArg: T, ...args: A): R @@ -423,7 +423,7 @@ "kind": "operator" }, { - "text": "1", + "text": "2", "kind": "numericLiteral" }, { @@ -431,7 +431,7 @@ "kind": "space" }, { - "text": "overload", + "text": "overloads", "kind": "text" }, { @@ -1381,7 +1381,7 @@ "kind": "operator" }, { - "text": "1", + "text": "2", "kind": "numericLiteral" }, { @@ -1389,7 +1389,7 @@ "kind": "space" }, { - "text": "overload", + "text": "overloads", "kind": "text" }, { diff --git a/tests/baselines/reference/declarationEmitPromise.symbols b/tests/baselines/reference/declarationEmitPromise.symbols index 7f3d02bf8ab95..5e3e775a13e55 100644 --- a/tests/baselines/reference/declarationEmitPromise.symbols +++ b/tests/baselines/reference/declarationEmitPromise.symbols @@ -69,9 +69,9 @@ export async function runSampleWorks( >T : Symbol(T, Decl(declarationEmitPromise.ts, 7, 16)) f.apply(this, result); ->f.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>f.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >f : Symbol(f, Decl(declarationEmitPromise.ts, 7, 19)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >result : Symbol(result, Decl(declarationEmitPromise.ts, 6, 7)) let rfunc: typeof func & {} = func as any; // <- This is the only difference @@ -141,9 +141,9 @@ export async function runSampleBreaks( >T : Symbol(T, Decl(declarationEmitPromise.ts, 16, 16)) f.apply(this, result); ->f.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>f.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >f : Symbol(f, Decl(declarationEmitPromise.ts, 16, 19)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >result : Symbol(result, Decl(declarationEmitPromise.ts, 15, 7)) let rfunc: typeof func = func as any; // <- This is the only difference diff --git a/tests/baselines/reference/declarationEmitPromise.types b/tests/baselines/reference/declarationEmitPromise.types index 7d1fa6a8bd369..ff1484fa7e505 100644 --- a/tests/baselines/reference/declarationEmitPromise.types +++ b/tests/baselines/reference/declarationEmitPromise.types @@ -88,12 +88,12 @@ export async function runSampleWorks( f.apply(this, result); >f.apply(this, result) : T > : ^ ->f.apply : { (this: (this: T_1) => R, thisArg: T_1): R; (this: (this: T_1, ...args: A_1) => R, thisArg: T_1, args: A_1): R; } -> : ^^^^^^^^ ^^ ^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>f.apply : { (this: (this: T_1) => R, thisArg: T_1): R; (this: (this: T_1, ...args: A_1) => R, thisArg: T_1, args: A_1): R; >(this: (this: T_1, ...args: A_1) => R, thisArg: T_1, args: Args extends readonly any[] ? A_1 : Args): R; } +> : ^^^^^^^^ ^^ ^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >f : (a: A, b?: B, c?: C, d?: D, e?: E) => T > : ^ ^^ ^^ ^^^ ^^ ^^^ ^^ ^^^ ^^ ^^^ ^^^^^ ->apply : { (this: (this: T_1) => R, thisArg: T_1): R; (this: (this: T_1, ...args: A_1) => R, thisArg: T_1, args: A_1): R; } -> : ^^^^^^^^ ^^ ^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T_1) => R, thisArg: T_1): R; (this: (this: T_1, ...args: A_1) => R, thisArg: T_1, args: A_1): R; >(this: (this: T_1, ...args: A_1) => R, thisArg: T_1, args: Args extends readonly any[] ? A_1 : Args): R; } +> : ^^^^^^^^ ^^ ^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >this : any >result : any @@ -189,12 +189,12 @@ export async function runSampleBreaks( f.apply(this, result); >f.apply(this, result) : T > : ^ ->f.apply : { (this: (this: T_1) => R, thisArg: T_1): R; (this: (this: T_1, ...args: A_1) => R, thisArg: T_1, args: A_1): R; } -> : ^^^^^^^^ ^^ ^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>f.apply : { (this: (this: T_1) => R, thisArg: T_1): R; (this: (this: T_1, ...args: A_1) => R, thisArg: T_1, args: A_1): R; >(this: (this: T_1, ...args: A_1) => R, thisArg: T_1, args: Args extends readonly any[] ? A_1 : Args): R; } +> : ^^^^^^^^ ^^ ^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >f : (a: A, b?: B, c?: C, d?: D, e?: E) => T > : ^ ^^ ^^ ^^^ ^^ ^^^ ^^ ^^^ ^^ ^^^ ^^^^^ ->apply : { (this: (this: T_1) => R, thisArg: T_1): R; (this: (this: T_1, ...args: A_1) => R, thisArg: T_1, args: A_1): R; } -> : ^^^^^^^^ ^^ ^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T_1) => R, thisArg: T_1): R; (this: (this: T_1, ...args: A_1) => R, thisArg: T_1, args: A_1): R; >(this: (this: T_1, ...args: A_1) => R, thisArg: T_1, args: Args extends readonly any[] ? A_1 : Args): R; } +> : ^^^^^^^^ ^^ ^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >this : any >result : any diff --git a/tests/baselines/reference/emitSkipsThisWithRestParameter.errors.txt b/tests/baselines/reference/emitSkipsThisWithRestParameter.errors.txt index d5204de2c2a50..9b297cbe2e36c 100644 --- a/tests/baselines/reference/emitSkipsThisWithRestParameter.errors.txt +++ b/tests/baselines/reference/emitSkipsThisWithRestParameter.errors.txt @@ -1,5 +1,10 @@ -emitSkipsThisWithRestParameter.ts(3,31): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[base: any, ...args: any[]]'. - Source provides no match for required element at position 0 in target. +emitSkipsThisWithRestParameter.ts(3,31): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: any, base: any, ...args: any[]) => any, thisArg: any, args: [base: any, ...args: any[]]): any', gave the following error. + Argument of type 'any[]' is not assignable to parameter of type '[base: any, ...args: any[]]'. + Source provides no match for required element at position 0 in target. + Overload 2 of 3, '(this: (this: any, base: any, ...args: any[]) => any, thisArg: any, args: [base: any, ...args: any[]]): any', gave the following error. + Argument of type 'any[]' is not assignable to parameter of type '[base: any, ...args: any[]]'. + Source provides no match for required element at position 0 in target. ==== emitSkipsThisWithRestParameter.ts (1 errors) ==== @@ -7,8 +12,13 @@ emitSkipsThisWithRestParameter.ts(3,31): error TS2345: Argument of type 'any[]' return function(this: any, ...args: any[]) { return fn.apply(this, [ this ].concat(args)); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[base: any, ...args: any[]]'. -!!! error TS2345: Source provides no match for required element at position 0 in target. +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: any, base: any, ...args: any[]) => any, thisArg: any, args: [base: any, ...args: any[]]): any', gave the following error. +!!! error TS2769: Argument of type 'any[]' is not assignable to parameter of type '[base: any, ...args: any[]]'. +!!! error TS2769: Source provides no match for required element at position 0 in target. +!!! error TS2769: Overload 2 of 3, '(this: (this: any, base: any, ...args: any[]) => any, thisArg: any, args: [base: any, ...args: any[]]): any', gave the following error. +!!! error TS2769: Argument of type 'any[]' is not assignable to parameter of type '[base: any, ...args: any[]]'. +!!! error TS2769: Source provides no match for required element at position 0 in target. }; } \ No newline at end of file diff --git a/tests/baselines/reference/emitSkipsThisWithRestParameter.symbols b/tests/baselines/reference/emitSkipsThisWithRestParameter.symbols index d9ce8acf67ff8..c1ed68b129160 100644 --- a/tests/baselines/reference/emitSkipsThisWithRestParameter.symbols +++ b/tests/baselines/reference/emitSkipsThisWithRestParameter.symbols @@ -13,9 +13,9 @@ function rebase(fn: (base: any, ...args: any[]) => any): (...args: any[]) => any >args : Symbol(args, Decl(emitSkipsThisWithRestParameter.ts, 1, 30)) return fn.apply(this, [ this ].concat(args)); ->fn.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>fn.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >fn : Symbol(fn, Decl(emitSkipsThisWithRestParameter.ts, 0, 16)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >this : Symbol(this, Decl(emitSkipsThisWithRestParameter.ts, 1, 20)) >[ this ].concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >this : Symbol(this, Decl(emitSkipsThisWithRestParameter.ts, 1, 20)) diff --git a/tests/baselines/reference/emitSkipsThisWithRestParameter.types b/tests/baselines/reference/emitSkipsThisWithRestParameter.types index 6621a5aefac69..3691603cc875c 100644 --- a/tests/baselines/reference/emitSkipsThisWithRestParameter.types +++ b/tests/baselines/reference/emitSkipsThisWithRestParameter.types @@ -24,12 +24,12 @@ function rebase(fn: (base: any, ...args: any[]) => any): (...args: any[]) => any return fn.apply(this, [ this ].concat(args)); >fn.apply(this, [ this ].concat(args)) : any > : ^^^ ->fn.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>fn.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >fn : (base: any, ...args: any[]) => any > : ^ ^^ ^^^^^ ^^ ^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >this : any > : ^^^ >[ this ].concat(args) : any[] diff --git a/tests/baselines/reference/esDecorators-contextualTypes.2.symbols b/tests/baselines/reference/esDecorators-contextualTypes.2.symbols index 6bef577a7e609..50230a13c011f 100644 --- a/tests/baselines/reference/esDecorators-contextualTypes.2.symbols +++ b/tests/baselines/reference/esDecorators-contextualTypes.2.symbols @@ -102,9 +102,9 @@ function boundMethodLogger(source: string, bou >toString : Symbol(toString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) return target.apply(this, args); ->target.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>target.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >target : Symbol(target, Decl(esDecorators-contextualTypes.2.ts, 13, 36)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >this : Symbol(this, Decl(esDecorators-contextualTypes.2.ts, 24, 25)) >args : Symbol(args, Decl(esDecorators-contextualTypes.2.ts, 24, 30)) } diff --git a/tests/baselines/reference/esDecorators-contextualTypes.2.types b/tests/baselines/reference/esDecorators-contextualTypes.2.types index 098f29ee6fa6d..8acb44af1962e 100644 --- a/tests/baselines/reference/esDecorators-contextualTypes.2.types +++ b/tests/baselines/reference/esDecorators-contextualTypes.2.types @@ -177,12 +177,12 @@ function boundMethodLogger(source: string, bou return target.apply(this, args); >target.apply(this, args) : Return > : ^^^^^^ ->target.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>target.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args_1 extends readonly any[] ? A : Args_1): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >target : (this: This, ...args: Args) => Return > : ^ ^^ ^^^^^ ^^ ^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args_1 extends readonly any[] ? A : Args_1): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >this : This > : ^^^^ >args : Args diff --git a/tests/baselines/reference/functionType.symbols b/tests/baselines/reference/functionType.symbols index 87327f9e0b939..41e8637b22c14 100644 --- a/tests/baselines/reference/functionType.symbols +++ b/tests/baselines/reference/functionType.symbols @@ -5,9 +5,9 @@ function salt() {} >salt : Symbol(salt, Decl(functionType.ts, 0, 0)) salt.apply("hello", []); ->salt.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>salt.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >salt : Symbol(salt, Decl(functionType.ts, 0, 0)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) (new Function("return 5"))(); >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) diff --git a/tests/baselines/reference/functionType.types b/tests/baselines/reference/functionType.types index 93b5f2e8b1b00..144a3d357743a 100644 --- a/tests/baselines/reference/functionType.types +++ b/tests/baselines/reference/functionType.types @@ -8,12 +8,12 @@ function salt() {} salt.apply("hello", []); >salt.apply("hello", []) : void > : ^^^^ ->salt.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>salt.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >salt : () => void > : ^^^^^^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >"hello" : "hello" > : ^^^^^^^ >[] : [] diff --git a/tests/baselines/reference/noParameterReassignmentIIFEAnnotated.errors.txt b/tests/baselines/reference/noParameterReassignmentIIFEAnnotated.errors.txt index ab4f5821d0756..1ad93d34a5795 100644 --- a/tests/baselines/reference/noParameterReassignmentIIFEAnnotated.errors.txt +++ b/tests/baselines/reference/noParameterReassignmentIIFEAnnotated.errors.txt @@ -1,10 +1,8 @@ index.js(3,28): error TS8029: JSDoc '@param' tag has name 'rest', but there is no parameter with that name. It would match 'arguments' if it had an array type. index.js(6,36): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -index.js(6,42): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'string[]'. - Type 'IArguments' is missing the following properties from type 'string[]': pop, push, concat, join, and 23 more. -==== index.js (3 errors) ==== +==== index.js (2 errors) ==== self.importScripts = (function (importScripts) { /** * @param {...unknown} rest @@ -15,9 +13,6 @@ index.js(6,42): error TS2345: Argument of type 'IArguments' is not assignable to return importScripts.apply(this, arguments); ~~~~ !!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. - ~~~~~~~~~ -!!! error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'string[]'. -!!! error TS2345: Type 'IArguments' is missing the following properties from type 'string[]': pop, push, concat, join, and 23 more. }; })(importScripts); \ No newline at end of file diff --git a/tests/baselines/reference/noParameterReassignmentIIFEAnnotated.symbols b/tests/baselines/reference/noParameterReassignmentIIFEAnnotated.symbols index 6e462074f9249..9319ce9922915 100644 --- a/tests/baselines/reference/noParameterReassignmentIIFEAnnotated.symbols +++ b/tests/baselines/reference/noParameterReassignmentIIFEAnnotated.symbols @@ -12,9 +12,9 @@ self.importScripts = (function (importScripts) { */ return function () { return importScripts.apply(this, arguments); ->importScripts.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>importScripts.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >importScripts : Symbol(importScripts, Decl(index.js, 0, 32)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arguments : Symbol(arguments) }; diff --git a/tests/baselines/reference/noParameterReassignmentIIFEAnnotated.types b/tests/baselines/reference/noParameterReassignmentIIFEAnnotated.types index 4f73e37e72153..dd7a6a25f655f 100644 --- a/tests/baselines/reference/noParameterReassignmentIIFEAnnotated.types +++ b/tests/baselines/reference/noParameterReassignmentIIFEAnnotated.types @@ -32,12 +32,12 @@ self.importScripts = (function (importScripts) { return importScripts.apply(this, arguments); >importScripts.apply(this, arguments) : void > : ^^^^ ->importScripts.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>importScripts.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >importScripts : (...urls: string[]) => void > : ^^^^ ^^ ^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >this : any > : ^^^ >arguments : IArguments diff --git a/tests/baselines/reference/noParameterReassignmentJSIIFE.errors.txt b/tests/baselines/reference/noParameterReassignmentJSIIFE.errors.txt deleted file mode 100644 index 3c0dc805022c7..0000000000000 --- a/tests/baselines/reference/noParameterReassignmentJSIIFE.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -index.js(3,42): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'string[]'. - Type 'IArguments' is missing the following properties from type 'string[]': pop, push, concat, join, and 23 more. - - -==== index.js (1 errors) ==== - self.importScripts = (function (importScripts) { - return function () { - return importScripts.apply(this, arguments); - ~~~~~~~~~ -!!! error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'string[]'. -!!! error TS2345: Type 'IArguments' is missing the following properties from type 'string[]': pop, push, concat, join, and 23 more. - }; - })(importScripts); - \ No newline at end of file diff --git a/tests/baselines/reference/noParameterReassignmentJSIIFE.symbols b/tests/baselines/reference/noParameterReassignmentJSIIFE.symbols index d575085256f16..a51be73c9a0a5 100644 --- a/tests/baselines/reference/noParameterReassignmentJSIIFE.symbols +++ b/tests/baselines/reference/noParameterReassignmentJSIIFE.symbols @@ -9,9 +9,9 @@ self.importScripts = (function (importScripts) { return function () { return importScripts.apply(this, arguments); ->importScripts.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>importScripts.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >importScripts : Symbol(importScripts, Decl(index.js, 0, 32)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arguments : Symbol(arguments) }; diff --git a/tests/baselines/reference/noParameterReassignmentJSIIFE.types b/tests/baselines/reference/noParameterReassignmentJSIIFE.types index dda35128dd66b..25ff5d70aa666 100644 --- a/tests/baselines/reference/noParameterReassignmentJSIIFE.types +++ b/tests/baselines/reference/noParameterReassignmentJSIIFE.types @@ -29,14 +29,13 @@ self.importScripts = (function (importScripts) { return importScripts.apply(this, arguments); >importScripts.apply(this, arguments) : void > : ^^^^ ->importScripts.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>importScripts.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >importScripts : (...urls: string[]) => void > : ^^^^ ^^ ^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >this : any -> : ^^^ >arguments : IArguments > : ^^^^^^^^^^ diff --git a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols index 0efa568e8b749..aa354cc492e53 100644 --- a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols +++ b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols @@ -22,9 +22,9 @@ var r2b: (x: any, y?: any) => any = i.apply; >r2b : Symbol(r2b, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 9, 3)) >x : Symbol(x, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 9, 10)) >y : Symbol(y, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 9, 17)) ->i.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>i.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >i : Symbol(i, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 7, 3)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) var b: { >b : Symbol(b, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 11, 3)) @@ -40,7 +40,7 @@ var rb4: (x: any, y?: any) => any = b.apply; >rb4 : Symbol(rb4, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 16, 3)) >x : Symbol(x, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 16, 10)) >y : Symbol(y, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 16, 17)) ->b.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>b.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >b : Symbol(b, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 11, 3)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) diff --git a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types index ee3dd1bc209c6..e9948b218cd53 100644 --- a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types +++ b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types @@ -27,12 +27,12 @@ var r2b: (x: any, y?: any) => any = i.apply; > : ^^^ >y : any > : ^^^ ->i.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>i.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >i : I > : ^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ var b: { >b : () => void @@ -56,10 +56,10 @@ var rb4: (x: any, y?: any) => any = b.apply; > : ^^^ >y : any > : ^^^ ->b.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>b.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >b : () => void > : ^^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ diff --git a/tests/baselines/reference/strictBindCallApply1.errors.txt b/tests/baselines/reference/strictBindCallApply1.errors.txt index a722def945fcc..96c49f27b5a8c 100644 --- a/tests/baselines/reference/strictBindCallApply1.errors.txt +++ b/tests/baselines/reference/strictBindCallApply1.errors.txt @@ -2,11 +2,25 @@ strictBindCallApply1.ts(11,35): error TS2345: Argument of type 'number' is not a strictBindCallApply1.ts(17,15): error TS2554: Expected 3 arguments, but got 2. strictBindCallApply1.ts(18,35): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. strictBindCallApply1.ts(19,44): error TS2554: Expected 3 arguments, but got 4. -strictBindCallApply1.ts(22,32): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. - Source has 1 element(s) but target requires 2. -strictBindCallApply1.ts(23,37): error TS2322: Type 'number' is not assignable to type 'string'. -strictBindCallApply1.ts(24,32): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. - Source has 3 element(s) but target allows only 2. +strictBindCallApply1.ts(22,32): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. + Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. + Source has 1 element(s) but target requires 2. + Overload 2 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. + Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. + Source has 1 element(s) but target requires 2. +strictBindCallApply1.ts(23,37): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. + Type 'number' is not assignable to type 'string'. + Overload 2 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. + Type 'number' is not assignable to type 'string'. +strictBindCallApply1.ts(24,32): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. + Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. + Source has 3 element(s) but target allows only 2. + Overload 2 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. + Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. + Source has 3 element(s) but target allows only 2. strictBindCallApply1.ts(41,29): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. strictBindCallApply1.ts(42,22): error TS2769: No overload matches this call. Overload 1 of 2, '(this: (this: C, a: number, b: string) => string, thisArg: C): (a: number, b: string) => string', gave the following error. @@ -17,12 +31,30 @@ strictBindCallApply1.ts(48,17): error TS2554: Expected 3 arguments, but got 2. strictBindCallApply1.ts(49,29): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. strictBindCallApply1.ts(50,38): error TS2554: Expected 3 arguments, but got 4. strictBindCallApply1.ts(51,22): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'. -strictBindCallApply1.ts(54,26): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. - Source has 1 element(s) but target requires 2. -strictBindCallApply1.ts(55,31): error TS2322: Type 'number' is not assignable to type 'string'. -strictBindCallApply1.ts(56,26): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. - Source has 3 element(s) but target allows only 2. -strictBindCallApply1.ts(57,23): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'. +strictBindCallApply1.ts(54,26): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. + Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. + Source has 1 element(s) but target requires 2. + Overload 2 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. + Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. + Source has 1 element(s) but target requires 2. +strictBindCallApply1.ts(55,31): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. + Type 'number' is not assignable to type 'string'. + Overload 2 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. + Type 'number' is not assignable to type 'string'. +strictBindCallApply1.ts(56,26): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. + Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. + Source has 3 element(s) but target allows only 2. + Overload 2 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. + Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. + Source has 3 element(s) but target allows only 2. +strictBindCallApply1.ts(57,23): error TS2769: No overload matches this call. + Overload 1 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. + Argument of type 'undefined' is not assignable to parameter of type 'C'. + Overload 2 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. + Argument of type 'undefined' is not assignable to parameter of type 'C'. strictBindCallApply1.ts(62,33): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. strictBindCallApply1.ts(65,3): error TS2554: Expected 3 arguments, but got 2. strictBindCallApply1.ts(66,15): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. @@ -81,15 +113,29 @@ strictBindCallApply1.ts(81,14): error TS2769: No overload matches this call. let a00 = foo.apply(undefined, [10, "hello"]); let a01 = foo.apply(undefined, [10]); // Error ~~~~ -!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. -!!! error TS2345: Source has 1 element(s) but target requires 2. +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. +!!! error TS2769: Source has 1 element(s) but target requires 2. +!!! error TS2769: Overload 2 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. +!!! error TS2769: Source has 1 element(s) but target requires 2. let a02 = foo.apply(undefined, [10, 20]); // Error ~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Type 'number' is not assignable to type 'string'. +!!! error TS2769: Overload 2 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Type 'number' is not assignable to type 'string'. let a03 = foo.apply(undefined, [10, "hello", 30]); // Error ~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. -!!! error TS2345: Source has 3 element(s) but target allows only 2. +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. +!!! error TS2769: Source has 3 element(s) but target allows only 2. +!!! error TS2769: Overload 2 of 3, '(this: (this: undefined, a: number, b: string) => string, thisArg: undefined, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. +!!! error TS2769: Source has 3 element(s) but target allows only 2. class C { constructor(a: number, b: string) {} @@ -137,18 +183,36 @@ strictBindCallApply1.ts(81,14): error TS2769: No overload matches this call. let a10 = c.foo.apply(c, [10, "hello"]); let a11 = c.foo.apply(c, [10]); // Error ~~~~ -!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. -!!! error TS2345: Source has 1 element(s) but target requires 2. +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. +!!! error TS2769: Source has 1 element(s) but target requires 2. +!!! error TS2769: Overload 2 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'. +!!! error TS2769: Source has 1 element(s) but target requires 2. let a12 = c.foo.apply(c, [10, 20]); // Error ~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Type 'number' is not assignable to type 'string'. +!!! error TS2769: Overload 2 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Type 'number' is not assignable to type 'string'. let a13 = c.foo.apply(c, [10, "hello", 30]); // Error ~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. -!!! error TS2345: Source has 3 element(s) but target allows only 2. +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. +!!! error TS2769: Source has 3 element(s) but target allows only 2. +!!! error TS2769: Overload 2 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'. +!!! error TS2769: Source has 3 element(s) but target allows only 2. let a14 = c.foo.apply(undefined, [10, "hello"]); // Error ~~~~~~~~~ -!!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'. +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Argument of type 'undefined' is not assignable to parameter of type 'C'. +!!! error TS2769: Overload 2 of 3, '(this: (this: C, a: number, b: string) => string, thisArg: C, args: [a: number, b: string]): string', gave the following error. +!!! error TS2769: Argument of type 'undefined' is not assignable to parameter of type 'C'. let f20 = C.bind(undefined); let f21 = C.bind(undefined, 10); diff --git a/tests/baselines/reference/strictBindCallApply1.symbols b/tests/baselines/reference/strictBindCallApply1.symbols index 6fc509232c8ca..a450137f53013 100644 --- a/tests/baselines/reference/strictBindCallApply1.symbols +++ b/tests/baselines/reference/strictBindCallApply1.symbols @@ -93,30 +93,30 @@ let c03 = foo.call(undefined, 10, "hello", 30); // Error let a00 = foo.apply(undefined, [10, "hello"]); >a00 : Symbol(a00, Decl(strictBindCallApply1.ts, 20, 3)) ->foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) let a01 = foo.apply(undefined, [10]); // Error >a01 : Symbol(a01, Decl(strictBindCallApply1.ts, 21, 3)) ->foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) let a02 = foo.apply(undefined, [10, 20]); // Error >a02 : Symbol(a02, Decl(strictBindCallApply1.ts, 22, 3)) ->foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) let a03 = foo.apply(undefined, [10, "hello", 30]); // Error >a03 : Symbol(a03, Decl(strictBindCallApply1.ts, 23, 3)) ->foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >foo : Symbol(foo, Decl(strictBindCallApply1.ts, 0, 0)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) class C { @@ -271,47 +271,47 @@ let c14 = c.foo.call(undefined, 10, "hello"); // Error let a10 = c.foo.apply(c, [10, "hello"]); >a10 : Symbol(a10, Decl(strictBindCallApply1.ts, 52, 3)) ->c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 26, 40)) >c : Symbol(c, Decl(strictBindCallApply1.ts, 34, 11)) >foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 26, 40)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >c : Symbol(c, Decl(strictBindCallApply1.ts, 34, 11)) let a11 = c.foo.apply(c, [10]); // Error >a11 : Symbol(a11, Decl(strictBindCallApply1.ts, 53, 3)) ->c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 26, 40)) >c : Symbol(c, Decl(strictBindCallApply1.ts, 34, 11)) >foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 26, 40)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >c : Symbol(c, Decl(strictBindCallApply1.ts, 34, 11)) let a12 = c.foo.apply(c, [10, 20]); // Error >a12 : Symbol(a12, Decl(strictBindCallApply1.ts, 54, 3)) ->c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 26, 40)) >c : Symbol(c, Decl(strictBindCallApply1.ts, 34, 11)) >foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 26, 40)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >c : Symbol(c, Decl(strictBindCallApply1.ts, 34, 11)) let a13 = c.foo.apply(c, [10, "hello", 30]); // Error >a13 : Symbol(a13, Decl(strictBindCallApply1.ts, 55, 3)) ->c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 26, 40)) >c : Symbol(c, Decl(strictBindCallApply1.ts, 34, 11)) >foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 26, 40)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >c : Symbol(c, Decl(strictBindCallApply1.ts, 34, 11)) let a14 = c.foo.apply(undefined, [10, "hello"]); // Error >a14 : Symbol(a14, Decl(strictBindCallApply1.ts, 56, 3)) ->c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>c.foo.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >c.foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 26, 40)) >c : Symbol(c, Decl(strictBindCallApply1.ts, 34, 11)) >foo : Symbol(C.foo, Decl(strictBindCallApply1.ts, 26, 40)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) let f20 = C.bind(undefined); diff --git a/tests/baselines/reference/strictBindCallApply1.types b/tests/baselines/reference/strictBindCallApply1.types index ff2f612e1cad6..46c45fba7885a 100644 --- a/tests/baselines/reference/strictBindCallApply1.types +++ b/tests/baselines/reference/strictBindCallApply1.types @@ -198,12 +198,12 @@ let a00 = foo.apply(undefined, [10, "hello"]); > : ^^^^^^ >foo.apply(undefined, [10, "hello"]) : string > : ^^^^^^ ->foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >foo : (a: number, b: string) => string > : ^ ^^ ^^ ^^ ^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >undefined : undefined > : ^^^^^^^^^ >[10, "hello"] : [number, string] @@ -218,12 +218,12 @@ let a01 = foo.apply(undefined, [10]); // Error > : ^^^^^^ >foo.apply(undefined, [10]) : string > : ^^^^^^ ->foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >foo : (a: number, b: string) => string > : ^ ^^ ^^ ^^ ^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >undefined : undefined > : ^^^^^^^^^ >[10] : [number] @@ -236,12 +236,12 @@ let a02 = foo.apply(undefined, [10, 20]); // Error > : ^^^^^^ >foo.apply(undefined, [10, 20]) : string > : ^^^^^^ ->foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >foo : (a: number, b: string) => string > : ^ ^^ ^^ ^^ ^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >undefined : undefined > : ^^^^^^^^^ >[10, 20] : [number, number] @@ -256,12 +256,12 @@ let a03 = foo.apply(undefined, [10, "hello", 30]); // Error > : ^^^^^^ >foo.apply(undefined, [10, "hello", 30]) : string > : ^^^^^^ ->foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >foo : (a: number, b: string) => string > : ^ ^^ ^^ ^^ ^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >undefined : undefined > : ^^^^^^^^^ >[10, "hello", 30] : [number, string, number] @@ -585,16 +585,16 @@ let a10 = c.foo.apply(c, [10, "hello"]); > : ^^^^^^ >c.foo.apply(c, [10, "hello"]) : string > : ^^^^^^ ->c.foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>c.foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >c.foo : (this: C, a: number, b: string) => string > : ^ ^^^^^ ^^ ^^ ^^ ^^^^^ >c : C > : ^ >foo : (this: C, a: number, b: string) => string > : ^ ^^^^^ ^^ ^^ ^^ ^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >c : C > : ^ >[10, "hello"] : [number, string] @@ -609,16 +609,16 @@ let a11 = c.foo.apply(c, [10]); // Error > : ^^^^^^ >c.foo.apply(c, [10]) : string > : ^^^^^^ ->c.foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>c.foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >c.foo : (this: C, a: number, b: string) => string > : ^ ^^^^^ ^^ ^^ ^^ ^^^^^ >c : C > : ^ >foo : (this: C, a: number, b: string) => string > : ^ ^^^^^ ^^ ^^ ^^ ^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >c : C > : ^ >[10] : [number] @@ -631,16 +631,16 @@ let a12 = c.foo.apply(c, [10, 20]); // Error > : ^^^^^^ >c.foo.apply(c, [10, 20]) : string > : ^^^^^^ ->c.foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>c.foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >c.foo : (this: C, a: number, b: string) => string > : ^ ^^^^^ ^^ ^^ ^^ ^^^^^ >c : C > : ^ >foo : (this: C, a: number, b: string) => string > : ^ ^^^^^ ^^ ^^ ^^ ^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >c : C > : ^ >[10, 20] : [number, number] @@ -655,16 +655,16 @@ let a13 = c.foo.apply(c, [10, "hello", 30]); // Error > : ^^^^^^ >c.foo.apply(c, [10, "hello", 30]) : string > : ^^^^^^ ->c.foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>c.foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >c.foo : (this: C, a: number, b: string) => string > : ^ ^^^^^ ^^ ^^ ^^ ^^^^^ >c : C > : ^ >foo : (this: C, a: number, b: string) => string > : ^ ^^^^^ ^^ ^^ ^^ ^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >c : C > : ^ >[10, "hello", 30] : [number, string, number] @@ -681,16 +681,16 @@ let a14 = c.foo.apply(undefined, [10, "hello"]); // Error > : ^^^^^^ >c.foo.apply(undefined, [10, "hello"]) : string > : ^^^^^^ ->c.foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>c.foo.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >c.foo : (this: C, a: number, b: string) => string > : ^ ^^^^^ ^^ ^^ ^^ ^^^^^ >c : C > : ^ >foo : (this: C, a: number, b: string) => string > : ^ ^^^^^ ^^ ^^ ^^ ^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >undefined : undefined > : ^^^^^^^^^ >[10, "hello"] : [number, string] diff --git a/tests/baselines/reference/truthinessCallExpressionCoercion2.symbols b/tests/baselines/reference/truthinessCallExpressionCoercion2.symbols index eb2e2cc793764..77832ad44c49b 100644 --- a/tests/baselines/reference/truthinessCallExpressionCoercion2.symbols +++ b/tests/baselines/reference/truthinessCallExpressionCoercion2.symbols @@ -87,9 +87,9 @@ function test(required1: () => boolean, required2: () => boolean, b: boolean, op >forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) >f : Symbol(f, Decl(truthinessCallExpressionCoercion2.ts, 37, 16)) >f : Symbol(f, Decl(truthinessCallExpressionCoercion2.ts, 37, 16)) ->f.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>f.apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >f : Symbol(f, Decl(truthinessCallExpressionCoercion2.ts, 37, 16)) ->apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(CallableFunction.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >parent : Symbol(parent, Decl(lib.dom.d.ts, --, --)) // error diff --git a/tests/baselines/reference/truthinessCallExpressionCoercion2.types b/tests/baselines/reference/truthinessCallExpressionCoercion2.types index 01bf1803364ef..205357e11e29a 100644 --- a/tests/baselines/reference/truthinessCallExpressionCoercion2.types +++ b/tests/baselines/reference/truthinessCallExpressionCoercion2.types @@ -217,12 +217,12 @@ function test(required1: () => boolean, required2: () => boolean, b: boolean, op > : ^^^^^^ >f.apply(parent, []) : void > : ^^^^ ->f.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>f.apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >f : () => void > : ^^^^^^ ->apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; } -> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ +>apply : { (this: (this: T) => R, thisArg: T): R; (this: (this: T, ...args: A) => R, thisArg: T, args: A): R; >(this: (this: T, ...args: A) => R, thisArg: T, args: Args extends readonly any[] ? A : Args): R; } +> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^ ^^^ >parent : Window > : ^^^^^^ >[] : [] diff --git a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).types b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).types index 40760fde6a54d..1fd94395a4abd 100644 --- a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).types +++ b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).types @@ -4,7 +4,7 @@ Assignability cache: 2,500 Type Count: 10,000 Instantiation count: 100,000 -Symbol count: 50,000 -> 100,000 +Symbol count: 100,000 === test.tsx === /// diff --git a/tests/cases/conformance/functions/applyArrayLike.ts b/tests/cases/conformance/functions/applyArrayLike.ts new file mode 100644 index 0000000000000..74723bc740a95 --- /dev/null +++ b/tests/cases/conformance/functions/applyArrayLike.ts @@ -0,0 +1,35 @@ +// @strict: true +// @target: es2015 +// @lib: es2015,dom + +// Repro for #61835: Function.prototype.apply accepts an array-like second argument +// per the ECMAScript spec (CreateListFromArrayLike), so CallableFunction.apply must +// accept ArrayLike, not just T[]. These cases work at runtime but previously errored. + +// --- Array-likes that should now be accepted --- + +declare const u8: Uint8Array; +const s1: string = String.fromCharCode.apply(null, u8); // Ok (Uint8Array is ArrayLike) + +const forwardArguments: (...args: unknown[]) => void = function () { + console.log.apply(null, arguments); // Ok (IArguments is array-like) +}; +forwardArguments(1, 2, 3); + +declare function variadic(...xs: number[]): void; +declare const arrayLikeNumbers: ArrayLike; +variadic.apply(undefined, arrayLikeNumbers); // Ok + +// A plain array/tuple still works via the arity-checked overload. +declare function foo(a: number, b: string): string; +const a00 = foo.apply(undefined, [10, "hello"]); // Ok + +// --- Regression guards: strictBindCallApply arity/element checks must be preserved --- + +const a01 = foo.apply(undefined, [10]); // Error: too few elements +const a02 = foo.apply(undefined, [10, 20]); // Error: wrong element type +const a03 = foo.apply(undefined, [10, "hello", 30]); // Error: too many elements + +// An array-like of the wrong element type must still be rejected. +declare const arrayLikeStrings: ArrayLike; +const bad = String.fromCharCode.apply(null, arrayLikeStrings); // Error: string is not number