File: mappedTypes1.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 (110 lines) | stat: -rw-r--r-- 3,779 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
=== tests/cases/conformance/types/mapped/mappedTypes1.ts ===
type Item = { a: string, b: number, c: boolean };
>Item : { a: string; b: number; c: boolean; }
>a : string
>b : number
>c : boolean

type T00 = { [P in "x" | "y"]: number };
>T00 : { x: number; y: number; }

type T01 = { [P in "x" | "y"]: P };
>T01 : { x: "x"; y: "y"; }

type T02 = { [P in "a" | "b"]: Item[P]; }
>T02 : { a: string; b: number; }

type T03 = { [P in keyof Item]: Date };
>T03 : { a: Date; b: Date; c: Date; }

type T10 = { [P in keyof Item]: Item[P] };
>T10 : { a: string; b: number; c: boolean; }

type T11 = { [P in keyof Item]?: Item[P] };
>T11 : { a?: string | undefined; b?: number | undefined; c?: boolean | undefined; }

type T12 = { readonly [P in keyof Item]: Item[P] };
>T12 : { readonly a: string; readonly b: number; readonly c: boolean; }

type T13 = { readonly [P in keyof Item]?: Item[P] };
>T13 : { readonly a?: string | undefined; readonly b?: number | undefined; readonly c?: boolean | undefined; }

type T20 = { [P in keyof Item]: Item[P] | null };
>T20 : { a: string | null; b: number | null; c: boolean | null; }
>null : null

type T21 = { [P in keyof Item]: Array<Item[P]> };
>T21 : { a: string[]; b: number[]; c: boolean[]; }

type T30 = { [P in keyof any]: void };
>T30 : { [x: string]: void; }

type T31 = { [P in keyof string]: void };
>T31 : { [x: number]: void; toString: void; charAt: void; charCodeAt: void; concat: void; indexOf: void; lastIndexOf: void; localeCompare: void; match: void; replace: void; search: void; slice: void; split: void; substring: void; toLowerCase: void; toLocaleLowerCase: void; toUpperCase: void; toLocaleUpperCase: void; trim: void; readonly length: void; substr: void; valueOf: void; }

type T32 = { [P in keyof number]: void };
>T32 : { toString: void; toFixed: void; toExponential: void; toPrecision: void; valueOf: void; toLocaleString: void; }

type T33 = { [P in keyof boolean]: void };
>T33 : { valueOf: void; }

type T34 = { [P in keyof undefined]: void };
>T34 : {}

type T35 = { [P in keyof null]: void };
>T35 : {}
>null : null

type T36 = { [P in keyof void]: void };
>T36 : {}

type T37 = { [P in keyof symbol]: void };
>T37 : { toString: void; valueOf: void; }

type T38 = { [P in keyof never]: void };
>T38 : {}

type T40 = { [P in string]: void };
>T40 : { [x: string]: void; }

type T43 = { [P in "a" | "b"]: void };
>T43 : { a: void; b: void; }

type T44 = { [P in "a" | "b" | "0" | "1"]: void };
>T44 : { a: void; b: void; 0: void; 1: void; }

type T47 = { [P in string | "a" | "b" | "0" | "1"]: void };
>T47 : { [x: string]: void; }

declare function f1<T1>(): { [P in keyof T1]: void };
>f1 : <T1>() => { [P in keyof T1]: void; }

declare function f2<T1 extends string>(): { [P in keyof T1]: void };
>f2 : <T1 extends string>() => { [P in keyof T1]: void; }

declare function f3<T1 extends number>(): { [P in keyof T1]: void };
>f3 : <T1 extends number>() => { [P in keyof T1]: void; }

declare function f4<T1 extends Number>(): { [P in keyof T1]: void };
>f4 : <T1 extends Number>() => { [P in keyof T1]: void; }

let x1 = f1();
>x1 : {}
>f1() : {}
>f1 : <T1>() => { [P in keyof T1]: void; }

let x2 = f2();
>x2 : string
>f2() : string
>f2 : <T1 extends string>() => { [P in keyof T1]: void; }

let x3 = f3();
>x3 : number
>f3() : number
>f3 : <T1 extends number>() => { [P in keyof T1]: void; }

let x4 = f4();
>x4 : { toString: void; toFixed: void; toExponential: void; toPrecision: void; valueOf: void; toLocaleString: void; }
>f4() : { toString: void; toFixed: void; toExponential: void; toPrecision: void; valueOf: void; toLocaleString: void; }
>f4 : <T1 extends Number>() => { [P in keyof T1]: void; }