Skip to content

Commit 88f7759

Browse files
committed
Add tests
1 parent a0df1e3 commit 88f7759

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/cases/compiler/strictFunctionTypes1.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,27 @@ const x11 = f3(never, fo, fx); // "def"
2727

2828
declare function foo<T>(a: ReadonlyArray<T>): T;
2929
let x = foo([]); // never
30+
31+
// Modified repros from #26127
32+
33+
interface A { a: string }
34+
interface B extends A { b: string }
35+
36+
declare function acceptUnion(x: A | number): void;
37+
declare function acceptA(x: A): void;
38+
39+
declare let a: A;
40+
declare let b: B;
41+
declare let never: never;
42+
43+
declare function coAndContra<T>(value: T, func: (t: T) => void): T;
44+
45+
const t1: A = coAndContra(a, acceptUnion);
46+
const t2: B = coAndContra(b, acceptA);
47+
const t3: A = coAndContra(never, acceptA);
48+
49+
declare function coAndContraArray<T>(value: T[], func: (t: T) => void): T[];
50+
51+
const t4: A[] = coAndContraArray([a], acceptUnion);
52+
const t5: B[] = coAndContraArray([b], acceptA);
53+
const t6: A[] = coAndContraArray([], acceptA);

0 commit comments

Comments
 (0)