1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
tests/cases/compiler/recursiveTupleTypeInference.ts(23,5): error TS2345: Argument of type '{ b: A; }' is not assignable to parameter of type 'G<{ b: unknown; }>'.
Types of property 'b' are incompatible.
Type 'A' is not assignable to type '[never, "null"]'.
Type 'string' is not assignable to type '[never, "null"]'.
==== tests/cases/compiler/recursiveTupleTypeInference.ts (1 errors) ====
// Repro from #37475
export type A = "number" | "null" | A[];
export type F<T> = null extends T
? [F<NonNullable<T>>, "null"]
: T extends number
? "number"
: never;
export type G<T> = { [k in keyof T]: F<T[k]> };
interface K {
b: number | null;
}
const gK: { [key in keyof K]: A } = { b: ["number", "null"] };
function foo<T>(g: G<T>): T {
return {} as any;
}
foo(gK);
~~
!!! error TS2345: Argument of type '{ b: A; }' is not assignable to parameter of type 'G<{ b: unknown; }>'.
!!! error TS2345: Types of property 'b' are incompatible.
!!! error TS2345: Type 'A' is not assignable to type '[never, "null"]'.
!!! error TS2345: Type 'string' is not assignable to type '[never, "null"]'.
|