Accept new baselines

This commit is contained in:
Anders Hejlsberg
2018-08-25 07:55:21 -07:00
parent 676892ee56
commit 349bee92a3
4 changed files with 593 additions and 0 deletions

View File

@@ -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<any>) => void'.
tests/cases/conformance/types/rest/genericRestParameters3.ts(31,21): error TS2345: Argument of type '<T extends any[]>(cb: (...args: T) => void) => void' is not assignable to parameter of type '(...args: CoolArray<any>) => void'.
Types of parameters 'cb' and 'args' are incompatible.
Type 'CoolArray<any>' is not assignable to type '[(...args: any[]) => void]'.
Property '0' is missing in type 'CoolArray<any>'.
tests/cases/conformance/types/rest/genericRestParameters3.ts(38,32): error TS2345: Argument of type '[10, 20]' is not assignable to parameter of type 'CoolArray<number>'.
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<never>'.
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<number>'.
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<E> extends Array<E> {
hello: number;
}
declare function foo<T extends any[]>(cb: (...args: T) => void): void;
foo<CoolArray<any>>(); // Error
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 0.
foo<CoolArray<any>>(100); // Error
~~~
!!! error TS2345: Argument of type '100' is not assignable to parameter of type '(...args: CoolArray<any>) => void'.
foo<CoolArray<any>>(foo); // Error
~~~
!!! error TS2345: Argument of type '<T extends any[]>(cb: (...args: T) => void) => void' is not assignable to parameter of type '(...args: CoolArray<any>) => void'.
!!! error TS2345: Types of parameters 'cb' and 'args' are incompatible.
!!! error TS2345: Type 'CoolArray<any>' is not assignable to type '[(...args: any[]) => void]'.
!!! error TS2345: Property '0' is missing in type 'CoolArray<any>'.
function bar<T extends any[]>(...args: T): T {
return args;
}
let a = bar(10, 20);
let b = bar<CoolArray<number>>(10, 20); // Error
~~
!!! error TS2345: Argument of type '[10, 20]' is not assignable to parameter of type 'CoolArray<number>'.
!!! error TS2345: Property 'hello' is missing in type '[10, 20]'.
declare function baz<T>(...args: CoolArray<T>): void;
declare const ca: CoolArray<number>;
baz(); // Error
~~~~~
!!! error TS2345: Argument of type '[]' is not assignable to parameter of type 'CoolArray<never>'.
!!! 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<number>'.
!!! error TS2345: Property 'hello' is missing in type 'number[]'.
// Repro from #26491
declare function hmm<A extends [] | [number, string]>(...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"]'.

View File

@@ -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<E> extends Array<E> {
hello: number;
}
declare function foo<T extends any[]>(cb: (...args: T) => void): void;
foo<CoolArray<any>>(); // Error
foo<CoolArray<any>>(100); // Error
foo<CoolArray<any>>(foo); // Error
function bar<T extends any[]>(...args: T): T {
return args;
}
let a = bar(10, 20);
let b = bar<CoolArray<number>>(10, 20); // Error
declare function baz<T>(...args: CoolArray<T>): void;
declare const ca: CoolArray<number>;
baz(); // Error
baz(1); // Error
baz(1, 2); // Error
baz(...ca); // Error
// Repro from #26491
declare function hmm<A extends [] | [number, string]>(...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<E> extends Array<E> {
hello: number;
}
declare function foo<T extends any[]>(cb: (...args: T) => void): void;
declare function bar<T extends any[]>(...args: T): T;
declare let a: [number, number];
declare let b: any;
declare function baz<T>(...args: CoolArray<T>): void;
declare const ca: CoolArray<number>;
declare function hmm<A extends [] | [number, string]>(...args: A): void;

View File

@@ -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<E> extends Array<E> {
>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<T extends any[]>(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<CoolArray<any>>(); // Error
>foo : Symbol(foo, Decl(genericRestParameters3.ts, 24, 1))
>CoolArray : Symbol(CoolArray, Decl(genericRestParameters3.ts, 18, 8))
foo<CoolArray<any>>(100); // Error
>foo : Symbol(foo, Decl(genericRestParameters3.ts, 24, 1))
>CoolArray : Symbol(CoolArray, Decl(genericRestParameters3.ts, 18, 8))
foo<CoolArray<any>>(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<T extends any[]>(...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<CoolArray<number>>(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<T>(...args: CoolArray<T>): 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<number>;
>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<A extends [] | [number, string]>(...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))

View File

@@ -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<E> extends Array<E> {
hello: number;
>hello : number
}
declare function foo<T extends any[]>(cb: (...args: T) => void): void;
>foo : <T extends any[]>(cb: (...args: T) => void) => void
>cb : (...args: T) => void
>args : T
foo<CoolArray<any>>(); // Error
>foo<CoolArray<any>>() : any
>foo : <T extends any[]>(cb: (...args: T) => void) => void
foo<CoolArray<any>>(100); // Error
>foo<CoolArray<any>>(100) : any
>foo : <T extends any[]>(cb: (...args: T) => void) => void
>100 : 100
foo<CoolArray<any>>(foo); // Error
>foo<CoolArray<any>>(foo) : any
>foo : <T extends any[]>(cb: (...args: T) => void) => void
>foo : <T extends any[]>(cb: (...args: T) => void) => void
function bar<T extends any[]>(...args: T): T {
>bar : <T extends any[]>(...args: T) => T
>args : T
return args;
>args : T
}
let a = bar(10, 20);
>a : [number, number]
>bar(10, 20) : [number, number]
>bar : <T extends any[]>(...args: T) => T
>10 : 10
>20 : 20
let b = bar<CoolArray<number>>(10, 20); // Error
>b : any
>bar<CoolArray<number>>(10, 20) : any
>bar : <T extends any[]>(...args: T) => T
>10 : 10
>20 : 20
declare function baz<T>(...args: CoolArray<T>): void;
>baz : <T>(...args: CoolArray<T>) => void
>args : CoolArray<T>
declare const ca: CoolArray<number>;
>ca : CoolArray<number>
baz(); // Error
>baz() : any
>baz : <T>(...args: CoolArray<T>) => void
baz(1); // Error
>baz(1) : any
>baz : <T>(...args: CoolArray<T>) => void
>1 : 1
baz(1, 2); // Error
>baz(1, 2) : any
>baz : <T>(...args: CoolArray<T>) => void
>1 : 1
>2 : 2
baz(...ca); // Error
>baz(...ca) : any
>baz : <T>(...args: CoolArray<T>) => void
>...ca : number
>ca : CoolArray<number>
// Repro from #26491
declare function hmm<A extends [] | [number, string]>(...args: A): void;
>hmm : <A extends [] | [number, string]>(...args: A) => void
>args : A
hmm(); // okay, A = []
>hmm() : void
>hmm : <A extends [] | [number, string]>(...args: A) => void
hmm(1, "s"); // okay, A = [1, "s"]
>hmm(1, "s") : void
>hmm : <A extends [] | [number, string]>(...args: A) => void
>1 : 1
>"s" : "s"
hmm("what"); // no error? A = [] | [number, string] ?
>hmm("what") : any
>hmm : <A extends [] | [number, string]>(...args: A) => void
>"what" : "what"