File: recursiveTupleTypeInference.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 459,116 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (36 lines) | stat: -rw-r--r-- 1,272 bytes parent folder | download | duplicates (3)
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"]'.