File: mappedTypeWithAny.types

package info (click to toggle)
node-typescript 4.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 396,552 kB
  • sloc: javascript: 1,444,377; makefile: 7; sh: 3
file content (58 lines) | stat: -rw-r--r-- 1,069 bytes parent folder | download
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
=== tests/cases/conformance/types/mapped/mappedTypeWithAny.ts ===
type Item = { value: string };
>Item : Item
>value : string

type ItemMap<T> = { [P in keyof T]: Item };
>ItemMap : ItemMap<T>

declare let x0: keyof any;
>x0 : string | number | symbol

declare let x1: { [P in any]: Item };
>x1 : { [x: string]: Item; [x: number]: Item; }

declare let x2: { [P in string]: Item };
>x2 : { [x: string]: Item; }

declare let x3: { [P in keyof any]: Item };
>x3 : { [x: string]: Item; }

declare let x4: ItemMap<any>;
>x4 : ItemMap<any>

// Repro from #19152

type Data = {
>Data : Data

  value: string;
>value : string
}

type StrictDataMap<T> = {
>StrictDataMap : StrictDataMap<T>

  [P in keyof T]: Data
}

declare let z: StrictDataMap<any>;
>z : StrictDataMap<any>

for (let id in z) {
>id : string
>z : StrictDataMap<any>

  let data = z[id];
>data : Data
>z[id] : Data
>z : StrictDataMap<any>
>id : string

  let x = data.notAValue;  // Error
>x : any
>data.notAValue : any
>data : Data
>notAValue : any
}