File: mappedTypeErrors2.types

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 (43 lines) | stat: -rw-r--r-- 834 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
=== tests/cases/conformance/types/mapped/mappedTypeErrors2.ts ===
// Repros from #17238

type AB = {
>AB : { a: 'a'; b: 'a'; }

    a: 'a'
>a : "a"

    b: 'a'
>b : "a"

};

type T1<K extends keyof AB> = { [key in AB[K]]: true };
>T1 : T1<K>
>true : true

type T2<K extends 'a'|'b'> = T1<K>[K]; // Error
>T2 : T2<K>

type R = AB[keyof AB]; // "a"
>R : "a"

type T3 = { [key in R]: true };
>T3 : { a: true; }
>true : true

type T4<K extends 'a'|'b'> = T3[K] // Error
>T4 : T4<K>

type T5<S extends 'a'|'b'|'extra'> = {[key in AB[S]]: true}[S]; // Error
>T5 : T5<S>
>true : true

type T6<S extends 'a'|'b', L extends 'a'|'b'> = {[key in AB[S]]: true}[L]; // Error
>T6 : T6<S, L>
>true : true

type T7<S extends 'a'|'b', L extends 'a'> = {[key in AB[S]]: true}[L];
>T7 : T7<S, L>
>true : true