File: infiniteConstraints.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (66 lines) | stat: -rw-r--r-- 3,370 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
tests/cases/compiler/infiniteConstraints.ts(4,37): error TS2536: Type '"val"' cannot be used to index type 'B[Exclude<keyof B, K>]'.
tests/cases/compiler/infiniteConstraints.ts(31,43): error TS2322: Type 'Value<"dup">' is not assignable to type 'never'.
tests/cases/compiler/infiniteConstraints.ts(31,63): error TS2322: Type 'Value<"dup">' is not assignable to type 'never'.
tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2536: Type '"foo"' cannot be used to index type 'T[keyof T]'.


==== tests/cases/compiler/infiniteConstraints.ts (4 errors) ====
    // Both of the following types trigger the recursion limiter in getImmediateBaseConstraint
    
    type T1<B extends { [K in keyof B]: Extract<B[Exclude<keyof B, K>], { val: string }>["val"] }> = B;
    type T2<B extends { [K in keyof B]: B[Exclude<keyof B, K>]["val"] }> = B;
                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2536: Type '"val"' cannot be used to index type 'B[Exclude<keyof B, K>]'.
    
    // Repros from #22950
    
    type AProp<T extends { a: string }> = T
    
    declare function myBug<
      T extends { [K in keyof T]: T[K] extends AProp<infer U> ? U : never }
    >(arg: T): T
    
    const out = myBug({obj1: {a: "test"}})
    
    type Value<V extends string = string> = Record<"val", V>;
    declare function value<V extends string>(val: V): Value<V>;
    
    declare function ensureNoDuplicates<
      T extends {
        [K in keyof T]: Extract<T[K], Value>["val"] extends Extract<T[Exclude<keyof T, K>], Value>["val"]
          ? never
          : any
      }
    >(vals: T): void;
    
    const noError = ensureNoDuplicates({main: value("test"), alternate: value("test2")});
    
    const shouldBeNoError = ensureNoDuplicates({main: value("test")});
    
    const shouldBeError = ensureNoDuplicates({main: value("dup"), alternate: value("dup")});
                                              ~~~~
!!! error TS2322: Type 'Value<"dup">' is not assignable to type 'never'.
!!! related TS6500 tests/cases/compiler/infiniteConstraints.ts:31:43: The expected type comes from property 'main' which is declared here on type '{ main: never; alternate: never; }'
                                                                  ~~~~~~~~~
!!! error TS2322: Type 'Value<"dup">' is not assignable to type 'never'.
!!! related TS6500 tests/cases/compiler/infiniteConstraints.ts:31:63: The expected type comes from property 'alternate' which is declared here on type '{ main: never; alternate: never; }'
    
    // Repro from #26448
    
    type Cond<T> = T extends number ? number : never;
    declare function function1<T extends {[K in keyof T]: Cond<T[K]>}>(): T[keyof T]["foo"];
                                                                          ~~~~~~~~~~~~~~~~~
!!! error TS2536: Type '"foo"' cannot be used to index type 'T[keyof T]'.
    
    // Repro from #31823
    
    export type Prepend<Elm, T extends unknown[]> =
      T extends unknown ?
      ((arg: Elm, ...rest: T) => void) extends ((...args: infer T2) => void) ? T2 :
      never :
      never;
    export type ExactExtract<T, U> = T extends U ? U extends T ? T : never : never;
    
    type Conv<T, U = T> =
      { 0: [T]; 1: Prepend<T, Conv<ExactExtract<U, T>>>;}[U extends T ? 0 : 1];