Add tests
This commit is contained in:
parent
a0df1e35e9
commit
88f7759d6b
1 changed files with 24 additions and 0 deletions
|
@ -27,3 +27,27 @@ const x11 = f3(never, fo, fx); // "def"
|
||||||
|
|
||||||
declare function foo<T>(a: ReadonlyArray<T>): T;
|
declare function foo<T>(a: ReadonlyArray<T>): T;
|
||||||
let x = foo([]); // never
|
let x = foo([]); // never
|
||||||
|
|
||||||
|
// Modified repros from #26127
|
||||||
|
|
||||||
|
interface A { a: string }
|
||||||
|
interface B extends A { b: string }
|
||||||
|
|
||||||
|
declare function acceptUnion(x: A | number): void;
|
||||||
|
declare function acceptA(x: A): void;
|
||||||
|
|
||||||
|
declare let a: A;
|
||||||
|
declare let b: B;
|
||||||
|
declare let never: never;
|
||||||
|
|
||||||
|
declare function coAndContra<T>(value: T, func: (t: T) => void): T;
|
||||||
|
|
||||||
|
const t1: A = coAndContra(a, acceptUnion);
|
||||||
|
const t2: B = coAndContra(b, acceptA);
|
||||||
|
const t3: A = coAndContra(never, acceptA);
|
||||||
|
|
||||||
|
declare function coAndContraArray<T>(value: T[], func: (t: T) => void): T[];
|
||||||
|
|
||||||
|
const t4: A[] = coAndContraArray([a], acceptUnion);
|
||||||
|
const t5: B[] = coAndContraArray([b], acceptA);
|
||||||
|
const t6: A[] = coAndContraArray([], acceptA);
|
||||||
|
|
Loading…
Reference in a new issue