From 349bee92a34cf3550ae594213ad1eefabfb2f3df Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 25 Aug 2018 07:55:21 -0700 Subject: [PATCH] Accept new baselines --- .../genericRestParameters3.errors.txt | 148 ++++++++++++++ .../reference/genericRestParameters3.js | 106 ++++++++++ .../reference/genericRestParameters3.symbols | 157 +++++++++++++++ .../reference/genericRestParameters3.types | 182 ++++++++++++++++++ 4 files changed, 593 insertions(+) create mode 100644 tests/baselines/reference/genericRestParameters3.errors.txt create mode 100644 tests/baselines/reference/genericRestParameters3.js create mode 100644 tests/baselines/reference/genericRestParameters3.symbols create mode 100644 tests/baselines/reference/genericRestParameters3.types diff --git a/tests/baselines/reference/genericRestParameters3.errors.txt b/tests/baselines/reference/genericRestParameters3.errors.txt new file mode 100644 index 00000000000..1f028153397 --- /dev/null +++ b/tests/baselines/reference/genericRestParameters3.errors.txt @@ -0,0 +1,148 @@ +tests/cases/conformance/types/rest/genericRestParameters3.ts(11,11): error TS2345: Argument of type '[10]' is not assignable to parameter of type '[string] | [number, boolean]'. + Type '[10]' is not assignable to type '[string]'. + Type '10' is not assignable to type 'string'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(12,1): error TS2345: Argument of type '[]' is not assignable to parameter of type '[string] | [number, boolean]'. + Type '[]' is not assignable to type '[number, boolean]'. + Property '0' is missing in type '[]'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(16,1): error TS2322: Type '(x: string, ...args: [string] | [number, boolean]) => void' is not assignable to type '(...args: [string, string] | [string, number, boolean]) => void'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(17,1): error TS2322: Type '(x: string, y: string) => void' is not assignable to type '(x: string, ...args: [string] | [number, boolean]) => void'. + Types of parameters 'y' and 'args' are incompatible. + Type '[string] | [number, boolean]' is not assignable to type '[string]'. + Type '[number, boolean]' is not assignable to type '[string]'. + Types of property '0' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(18,1): error TS2322: Type '(x: string, y: number, z: boolean) => void' is not assignable to type '(x: string, ...args: [string] | [number, boolean]) => void'. + Types of parameters 'y' and 'args' are incompatible. + Type '[string] | [number, boolean]' is not assignable to type '[number, boolean]'. + Type '[string]' is not assignable to type '[number, boolean]'. + Property '1' is missing in type '[string]'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(19,1): error TS2322: Type '(...args: [string, string] | [string, number, boolean]) => void' is not assignable to type '(x: string, ...args: [string] | [number, boolean]) => void'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(29,1): error TS2554: Expected 1 arguments, but got 0. +tests/cases/conformance/types/rest/genericRestParameters3.ts(30,21): error TS2345: Argument of type '100' is not assignable to parameter of type '(...args: CoolArray) => void'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(31,21): error TS2345: Argument of type '(cb: (...args: T) => void) => void' is not assignable to parameter of type '(...args: CoolArray) => void'. + Types of parameters 'cb' and 'args' are incompatible. + Type 'CoolArray' is not assignable to type '[(...args: any[]) => void]'. + Property '0' is missing in type 'CoolArray'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(38,32): error TS2345: Argument of type '[10, 20]' is not assignable to parameter of type 'CoolArray'. + Property 'hello' is missing in type '[10, 20]'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(43,1): error TS2345: Argument of type '[]' is not assignable to parameter of type 'CoolArray'. + Property 'hello' is missing in type '[]'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(44,5): error TS2345: Argument of type '[number]' is not assignable to parameter of type 'CoolArray<{}>'. + Property 'hello' is missing in type '[number]'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(45,5): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type 'CoolArray<{}>'. + Property 'hello' is missing in type '[number, number]'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(46,5): error TS2345: Argument of type 'number[]' is not assignable to parameter of type 'CoolArray'. + Property 'hello' is missing in type 'number[]'. +tests/cases/conformance/types/rest/genericRestParameters3.ts(53,5): error TS2345: Argument of type '["what"]' is not assignable to parameter of type '[] | [number, string]'. + Type '["what"]' is not assignable to type '[number, string]'. + Property '1' is missing in type '["what"]'. + + +==== tests/cases/conformance/types/rest/genericRestParameters3.ts (15 errors) ==== + declare let f1: (x: string, ...args: [string] | [number, boolean]) => void; + declare let f2: (x: string, y: string) => void; + declare let f3: (x: string, y: number, z: boolean) => void; + declare let f4: (...args: [string, string] | [string, number, boolean]) => void; + + declare const tt: [string] | [number, boolean]; + + f1("foo", "abc"); + f1("foo", 10, true); + f1("foo", ...tt); + f1("foo", 10); // Error + ~~ +!!! error TS2345: Argument of type '[10]' is not assignable to parameter of type '[string] | [number, boolean]'. +!!! error TS2345: Type '[10]' is not assignable to type '[string]'. +!!! error TS2345: Type '10' is not assignable to type 'string'. + f1("foo"); // Error + ~~~~~~~~~ +!!! error TS2345: Argument of type '[]' is not assignable to parameter of type '[string] | [number, boolean]'. +!!! error TS2345: Type '[]' is not assignable to type '[number, boolean]'. +!!! error TS2345: Property '0' is missing in type '[]'. + + f2 = f1; + f3 = f1; + f4 = f1; // Error, misaligned complex rest types + ~~ +!!! error TS2322: Type '(x: string, ...args: [string] | [number, boolean]) => void' is not assignable to type '(...args: [string, string] | [string, number, boolean]) => void'. + f1 = f2; // Error + ~~ +!!! error TS2322: Type '(x: string, y: string) => void' is not assignable to type '(x: string, ...args: [string] | [number, boolean]) => void'. +!!! error TS2322: Types of parameters 'y' and 'args' are incompatible. +!!! error TS2322: Type '[string] | [number, boolean]' is not assignable to type '[string]'. +!!! error TS2322: Type '[number, boolean]' is not assignable to type '[string]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + f1 = f3; // Error + ~~ +!!! error TS2322: Type '(x: string, y: number, z: boolean) => void' is not assignable to type '(x: string, ...args: [string] | [number, boolean]) => void'. +!!! error TS2322: Types of parameters 'y' and 'args' are incompatible. +!!! error TS2322: Type '[string] | [number, boolean]' is not assignable to type '[number, boolean]'. +!!! error TS2322: Type '[string]' is not assignable to type '[number, boolean]'. +!!! error TS2322: Property '1' is missing in type '[string]'. + f1 = f4; // Error, misaligned complex rest types + ~~ +!!! error TS2322: Type '(...args: [string, string] | [string, number, boolean]) => void' is not assignable to type '(x: string, ...args: [string] | [number, boolean]) => void'. + + // Repro from #26110 + + interface CoolArray extends Array { + hello: number; + } + + declare function foo(cb: (...args: T) => void): void; + + foo>(); // Error + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2554: Expected 1 arguments, but got 0. + foo>(100); // Error + ~~~ +!!! error TS2345: Argument of type '100' is not assignable to parameter of type '(...args: CoolArray) => void'. + foo>(foo); // Error + ~~~ +!!! error TS2345: Argument of type '(cb: (...args: T) => void) => void' is not assignable to parameter of type '(...args: CoolArray) => void'. +!!! error TS2345: Types of parameters 'cb' and 'args' are incompatible. +!!! error TS2345: Type 'CoolArray' is not assignable to type '[(...args: any[]) => void]'. +!!! error TS2345: Property '0' is missing in type 'CoolArray'. + + function bar(...args: T): T { + return args; + } + + let a = bar(10, 20); + let b = bar>(10, 20); // Error + ~~ +!!! error TS2345: Argument of type '[10, 20]' is not assignable to parameter of type 'CoolArray'. +!!! error TS2345: Property 'hello' is missing in type '[10, 20]'. + + declare function baz(...args: CoolArray): void; + declare const ca: CoolArray; + + baz(); // Error + ~~~~~ +!!! error TS2345: Argument of type '[]' is not assignable to parameter of type 'CoolArray'. +!!! error TS2345: Property 'hello' is missing in type '[]'. + baz(1); // Error + ~ +!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type 'CoolArray<{}>'. +!!! error TS2345: Property 'hello' is missing in type '[number]'. + baz(1, 2); // Error + ~ +!!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type 'CoolArray<{}>'. +!!! error TS2345: Property 'hello' is missing in type '[number, number]'. + baz(...ca); // Error + ~~~~~ +!!! error TS2345: Argument of type 'number[]' is not assignable to parameter of type 'CoolArray'. +!!! error TS2345: Property 'hello' is missing in type 'number[]'. + + // Repro from #26491 + + declare function hmm(...args: A): void; + hmm(); // okay, A = [] + hmm(1, "s"); // okay, A = [1, "s"] + hmm("what"); // no error? A = [] | [number, string] ? + ~~~~~~ +!!! error TS2345: Argument of type '["what"]' is not assignable to parameter of type '[] | [number, string]'. +!!! error TS2345: Type '["what"]' is not assignable to type '[number, string]'. +!!! error TS2345: Property '1' is missing in type '["what"]'. + \ No newline at end of file diff --git a/tests/baselines/reference/genericRestParameters3.js b/tests/baselines/reference/genericRestParameters3.js new file mode 100644 index 00000000000..132edcbefb6 --- /dev/null +++ b/tests/baselines/reference/genericRestParameters3.js @@ -0,0 +1,106 @@ +//// [genericRestParameters3.ts] +declare let f1: (x: string, ...args: [string] | [number, boolean]) => void; +declare let f2: (x: string, y: string) => void; +declare let f3: (x: string, y: number, z: boolean) => void; +declare let f4: (...args: [string, string] | [string, number, boolean]) => void; + +declare const tt: [string] | [number, boolean]; + +f1("foo", "abc"); +f1("foo", 10, true); +f1("foo", ...tt); +f1("foo", 10); // Error +f1("foo"); // Error + +f2 = f1; +f3 = f1; +f4 = f1; // Error, misaligned complex rest types +f1 = f2; // Error +f1 = f3; // Error +f1 = f4; // Error, misaligned complex rest types + +// Repro from #26110 + +interface CoolArray extends Array { + hello: number; +} + +declare function foo(cb: (...args: T) => void): void; + +foo>(); // Error +foo>(100); // Error +foo>(foo); // Error + +function bar(...args: T): T { + return args; +} + +let a = bar(10, 20); +let b = bar>(10, 20); // Error + +declare function baz(...args: CoolArray): void; +declare const ca: CoolArray; + +baz(); // Error +baz(1); // Error +baz(1, 2); // Error +baz(...ca); // Error + +// Repro from #26491 + +declare function hmm(...args: A): void; +hmm(); // okay, A = [] +hmm(1, "s"); // okay, A = [1, "s"] +hmm("what"); // no error? A = [] | [number, string] ? + + +//// [genericRestParameters3.js] +"use strict"; +f1("foo", "abc"); +f1("foo", 10, true); +f1.apply(void 0, ["foo"].concat(tt)); +f1("foo", 10); // Error +f1("foo"); // Error +f2 = f1; +f3 = f1; +f4 = f1; // Error, misaligned complex rest types +f1 = f2; // Error +f1 = f3; // Error +f1 = f4; // Error, misaligned complex rest types +foo(); // Error +foo(100); // Error +foo(foo); // Error +function bar() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return args; +} +var a = bar(10, 20); +var b = bar(10, 20); // Error +baz(); // Error +baz(1); // Error +baz(1, 2); // Error +baz.apply(void 0, ca); // Error +hmm(); // okay, A = [] +hmm(1, "s"); // okay, A = [1, "s"] +hmm("what"); // no error? A = [] | [number, string] ? + + +//// [genericRestParameters3.d.ts] +declare let f1: (x: string, ...args: [string] | [number, boolean]) => void; +declare let f2: (x: string, y: string) => void; +declare let f3: (x: string, y: number, z: boolean) => void; +declare let f4: (...args: [string, string] | [string, number, boolean]) => void; +declare const tt: [string] | [number, boolean]; +interface CoolArray extends Array { + hello: number; +} +declare function foo(cb: (...args: T) => void): void; +declare function bar(...args: T): T; +declare let a: [number, number]; +declare let b: any; +declare function baz(...args: CoolArray): void; +declare const ca: CoolArray; +declare function hmm(...args: A): void; diff --git a/tests/baselines/reference/genericRestParameters3.symbols b/tests/baselines/reference/genericRestParameters3.symbols new file mode 100644 index 00000000000..a768f205b57 --- /dev/null +++ b/tests/baselines/reference/genericRestParameters3.symbols @@ -0,0 +1,157 @@ +=== tests/cases/conformance/types/rest/genericRestParameters3.ts === +declare let f1: (x: string, ...args: [string] | [number, boolean]) => void; +>f1 : Symbol(f1, Decl(genericRestParameters3.ts, 0, 11)) +>x : Symbol(x, Decl(genericRestParameters3.ts, 0, 17)) +>args : Symbol(args, Decl(genericRestParameters3.ts, 0, 27)) + +declare let f2: (x: string, y: string) => void; +>f2 : Symbol(f2, Decl(genericRestParameters3.ts, 1, 11)) +>x : Symbol(x, Decl(genericRestParameters3.ts, 1, 17)) +>y : Symbol(y, Decl(genericRestParameters3.ts, 1, 27)) + +declare let f3: (x: string, y: number, z: boolean) => void; +>f3 : Symbol(f3, Decl(genericRestParameters3.ts, 2, 11)) +>x : Symbol(x, Decl(genericRestParameters3.ts, 2, 17)) +>y : Symbol(y, Decl(genericRestParameters3.ts, 2, 27)) +>z : Symbol(z, Decl(genericRestParameters3.ts, 2, 38)) + +declare let f4: (...args: [string, string] | [string, number, boolean]) => void; +>f4 : Symbol(f4, Decl(genericRestParameters3.ts, 3, 11)) +>args : Symbol(args, Decl(genericRestParameters3.ts, 3, 17)) + +declare const tt: [string] | [number, boolean]; +>tt : Symbol(tt, Decl(genericRestParameters3.ts, 5, 13)) + +f1("foo", "abc"); +>f1 : Symbol(f1, Decl(genericRestParameters3.ts, 0, 11)) + +f1("foo", 10, true); +>f1 : Symbol(f1, Decl(genericRestParameters3.ts, 0, 11)) + +f1("foo", ...tt); +>f1 : Symbol(f1, Decl(genericRestParameters3.ts, 0, 11)) +>tt : Symbol(tt, Decl(genericRestParameters3.ts, 5, 13)) + +f1("foo", 10); // Error +>f1 : Symbol(f1, Decl(genericRestParameters3.ts, 0, 11)) + +f1("foo"); // Error +>f1 : Symbol(f1, Decl(genericRestParameters3.ts, 0, 11)) + +f2 = f1; +>f2 : Symbol(f2, Decl(genericRestParameters3.ts, 1, 11)) +>f1 : Symbol(f1, Decl(genericRestParameters3.ts, 0, 11)) + +f3 = f1; +>f3 : Symbol(f3, Decl(genericRestParameters3.ts, 2, 11)) +>f1 : Symbol(f1, Decl(genericRestParameters3.ts, 0, 11)) + +f4 = f1; // Error, misaligned complex rest types +>f4 : Symbol(f4, Decl(genericRestParameters3.ts, 3, 11)) +>f1 : Symbol(f1, Decl(genericRestParameters3.ts, 0, 11)) + +f1 = f2; // Error +>f1 : Symbol(f1, Decl(genericRestParameters3.ts, 0, 11)) +>f2 : Symbol(f2, Decl(genericRestParameters3.ts, 1, 11)) + +f1 = f3; // Error +>f1 : Symbol(f1, Decl(genericRestParameters3.ts, 0, 11)) +>f3 : Symbol(f3, Decl(genericRestParameters3.ts, 2, 11)) + +f1 = f4; // Error, misaligned complex rest types +>f1 : Symbol(f1, Decl(genericRestParameters3.ts, 0, 11)) +>f4 : Symbol(f4, Decl(genericRestParameters3.ts, 3, 11)) + +// Repro from #26110 + +interface CoolArray extends Array { +>CoolArray : Symbol(CoolArray, Decl(genericRestParameters3.ts, 18, 8)) +>E : Symbol(E, Decl(genericRestParameters3.ts, 22, 20)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>E : Symbol(E, Decl(genericRestParameters3.ts, 22, 20)) + + hello: number; +>hello : Symbol(CoolArray.hello, Decl(genericRestParameters3.ts, 22, 41)) +} + +declare function foo(cb: (...args: T) => void): void; +>foo : Symbol(foo, Decl(genericRestParameters3.ts, 24, 1)) +>T : Symbol(T, Decl(genericRestParameters3.ts, 26, 21)) +>cb : Symbol(cb, Decl(genericRestParameters3.ts, 26, 38)) +>args : Symbol(args, Decl(genericRestParameters3.ts, 26, 43)) +>T : Symbol(T, Decl(genericRestParameters3.ts, 26, 21)) + +foo>(); // Error +>foo : Symbol(foo, Decl(genericRestParameters3.ts, 24, 1)) +>CoolArray : Symbol(CoolArray, Decl(genericRestParameters3.ts, 18, 8)) + +foo>(100); // Error +>foo : Symbol(foo, Decl(genericRestParameters3.ts, 24, 1)) +>CoolArray : Symbol(CoolArray, Decl(genericRestParameters3.ts, 18, 8)) + +foo>(foo); // Error +>foo : Symbol(foo, Decl(genericRestParameters3.ts, 24, 1)) +>CoolArray : Symbol(CoolArray, Decl(genericRestParameters3.ts, 18, 8)) +>foo : Symbol(foo, Decl(genericRestParameters3.ts, 24, 1)) + +function bar(...args: T): T { +>bar : Symbol(bar, Decl(genericRestParameters3.ts, 30, 25)) +>T : Symbol(T, Decl(genericRestParameters3.ts, 32, 13)) +>args : Symbol(args, Decl(genericRestParameters3.ts, 32, 30)) +>T : Symbol(T, Decl(genericRestParameters3.ts, 32, 13)) +>T : Symbol(T, Decl(genericRestParameters3.ts, 32, 13)) + + return args; +>args : Symbol(args, Decl(genericRestParameters3.ts, 32, 30)) +} + +let a = bar(10, 20); +>a : Symbol(a, Decl(genericRestParameters3.ts, 36, 3)) +>bar : Symbol(bar, Decl(genericRestParameters3.ts, 30, 25)) + +let b = bar>(10, 20); // Error +>b : Symbol(b, Decl(genericRestParameters3.ts, 37, 3)) +>bar : Symbol(bar, Decl(genericRestParameters3.ts, 30, 25)) +>CoolArray : Symbol(CoolArray, Decl(genericRestParameters3.ts, 18, 8)) + +declare function baz(...args: CoolArray): void; +>baz : Symbol(baz, Decl(genericRestParameters3.ts, 37, 39)) +>T : Symbol(T, Decl(genericRestParameters3.ts, 39, 21)) +>args : Symbol(args, Decl(genericRestParameters3.ts, 39, 24)) +>CoolArray : Symbol(CoolArray, Decl(genericRestParameters3.ts, 18, 8)) +>T : Symbol(T, Decl(genericRestParameters3.ts, 39, 21)) + +declare const ca: CoolArray; +>ca : Symbol(ca, Decl(genericRestParameters3.ts, 40, 13)) +>CoolArray : Symbol(CoolArray, Decl(genericRestParameters3.ts, 18, 8)) + +baz(); // Error +>baz : Symbol(baz, Decl(genericRestParameters3.ts, 37, 39)) + +baz(1); // Error +>baz : Symbol(baz, Decl(genericRestParameters3.ts, 37, 39)) + +baz(1, 2); // Error +>baz : Symbol(baz, Decl(genericRestParameters3.ts, 37, 39)) + +baz(...ca); // Error +>baz : Symbol(baz, Decl(genericRestParameters3.ts, 37, 39)) +>ca : Symbol(ca, Decl(genericRestParameters3.ts, 40, 13)) + +// Repro from #26491 + +declare function hmm(...args: A): void; +>hmm : Symbol(hmm, Decl(genericRestParameters3.ts, 45, 11)) +>A : Symbol(A, Decl(genericRestParameters3.ts, 49, 21)) +>args : Symbol(args, Decl(genericRestParameters3.ts, 49, 54)) +>A : Symbol(A, Decl(genericRestParameters3.ts, 49, 21)) + +hmm(); // okay, A = [] +>hmm : Symbol(hmm, Decl(genericRestParameters3.ts, 45, 11)) + +hmm(1, "s"); // okay, A = [1, "s"] +>hmm : Symbol(hmm, Decl(genericRestParameters3.ts, 45, 11)) + +hmm("what"); // no error? A = [] | [number, string] ? +>hmm : Symbol(hmm, Decl(genericRestParameters3.ts, 45, 11)) + diff --git a/tests/baselines/reference/genericRestParameters3.types b/tests/baselines/reference/genericRestParameters3.types new file mode 100644 index 00000000000..8d8d145a44f --- /dev/null +++ b/tests/baselines/reference/genericRestParameters3.types @@ -0,0 +1,182 @@ +=== tests/cases/conformance/types/rest/genericRestParameters3.ts === +declare let f1: (x: string, ...args: [string] | [number, boolean]) => void; +>f1 : (x: string, ...args: [string] | [number, boolean]) => void +>x : string +>args : [string] | [number, boolean] + +declare let f2: (x: string, y: string) => void; +>f2 : (x: string, y: string) => void +>x : string +>y : string + +declare let f3: (x: string, y: number, z: boolean) => void; +>f3 : (x: string, y: number, z: boolean) => void +>x : string +>y : number +>z : boolean + +declare let f4: (...args: [string, string] | [string, number, boolean]) => void; +>f4 : (...args: [string, string] | [string, number, boolean]) => void +>args : [string, string] | [string, number, boolean] + +declare const tt: [string] | [number, boolean]; +>tt : [string] | [number, boolean] + +f1("foo", "abc"); +>f1("foo", "abc") : void +>f1 : (x: string, ...args: [string] | [number, boolean]) => void +>"foo" : "foo" +>"abc" : "abc" + +f1("foo", 10, true); +>f1("foo", 10, true) : void +>f1 : (x: string, ...args: [string] | [number, boolean]) => void +>"foo" : "foo" +>10 : 10 +>true : true + +f1("foo", ...tt); +>f1("foo", ...tt) : void +>f1 : (x: string, ...args: [string] | [number, boolean]) => void +>"foo" : "foo" +>...tt : string | number | boolean +>tt : [string] | [number, boolean] + +f1("foo", 10); // Error +>f1("foo", 10) : void +>f1 : (x: string, ...args: [string] | [number, boolean]) => void +>"foo" : "foo" +>10 : 10 + +f1("foo"); // Error +>f1("foo") : void +>f1 : (x: string, ...args: [string] | [number, boolean]) => void +>"foo" : "foo" + +f2 = f1; +>f2 = f1 : (x: string, ...args: [string] | [number, boolean]) => void +>f2 : (x: string, y: string) => void +>f1 : (x: string, ...args: [string] | [number, boolean]) => void + +f3 = f1; +>f3 = f1 : (x: string, ...args: [string] | [number, boolean]) => void +>f3 : (x: string, y: number, z: boolean) => void +>f1 : (x: string, ...args: [string] | [number, boolean]) => void + +f4 = f1; // Error, misaligned complex rest types +>f4 = f1 : (x: string, ...args: [string] | [number, boolean]) => void +>f4 : (...args: [string, string] | [string, number, boolean]) => void +>f1 : (x: string, ...args: [string] | [number, boolean]) => void + +f1 = f2; // Error +>f1 = f2 : (x: string, y: string) => void +>f1 : (x: string, ...args: [string] | [number, boolean]) => void +>f2 : (x: string, y: string) => void + +f1 = f3; // Error +>f1 = f3 : (x: string, y: number, z: boolean) => void +>f1 : (x: string, ...args: [string] | [number, boolean]) => void +>f3 : (x: string, y: number, z: boolean) => void + +f1 = f4; // Error, misaligned complex rest types +>f1 = f4 : (...args: [string, string] | [string, number, boolean]) => void +>f1 : (x: string, ...args: [string] | [number, boolean]) => void +>f4 : (...args: [string, string] | [string, number, boolean]) => void + +// Repro from #26110 + +interface CoolArray extends Array { + hello: number; +>hello : number +} + +declare function foo(cb: (...args: T) => void): void; +>foo : (cb: (...args: T) => void) => void +>cb : (...args: T) => void +>args : T + +foo>(); // Error +>foo>() : any +>foo : (cb: (...args: T) => void) => void + +foo>(100); // Error +>foo>(100) : any +>foo : (cb: (...args: T) => void) => void +>100 : 100 + +foo>(foo); // Error +>foo>(foo) : any +>foo : (cb: (...args: T) => void) => void +>foo : (cb: (...args: T) => void) => void + +function bar(...args: T): T { +>bar : (...args: T) => T +>args : T + + return args; +>args : T +} + +let a = bar(10, 20); +>a : [number, number] +>bar(10, 20) : [number, number] +>bar : (...args: T) => T +>10 : 10 +>20 : 20 + +let b = bar>(10, 20); // Error +>b : any +>bar>(10, 20) : any +>bar : (...args: T) => T +>10 : 10 +>20 : 20 + +declare function baz(...args: CoolArray): void; +>baz : (...args: CoolArray) => void +>args : CoolArray + +declare const ca: CoolArray; +>ca : CoolArray + +baz(); // Error +>baz() : any +>baz : (...args: CoolArray) => void + +baz(1); // Error +>baz(1) : any +>baz : (...args: CoolArray) => void +>1 : 1 + +baz(1, 2); // Error +>baz(1, 2) : any +>baz : (...args: CoolArray) => void +>1 : 1 +>2 : 2 + +baz(...ca); // Error +>baz(...ca) : any +>baz : (...args: CoolArray) => void +>...ca : number +>ca : CoolArray + +// Repro from #26491 + +declare function hmm(...args: A): void; +>hmm : (...args: A) => void +>args : A + +hmm(); // okay, A = [] +>hmm() : void +>hmm : (...args: A) => void + +hmm(1, "s"); // okay, A = [1, "s"] +>hmm(1, "s") : void +>hmm : (...args: A) => void +>1 : 1 +>"s" : "s" + +hmm("what"); // no error? A = [] | [number, string] ? +>hmm("what") : any +>hmm : (...args: A) => void +>"what" : "what" +