File: mappedTypes1.js

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (146 lines) | stat: -rw-r--r-- 3,514 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//// [mappedTypes1.ts]
type Item = { a: string, b: number, c: boolean };

type T00 = { [P in "x" | "y"]: number };
type T01 = { [P in "x" | "y"]: P };
type T02 = { [P in "a" | "b"]: Item[P]; }
type T03 = { [P in keyof Item]: Date };

type T10 = { [P in keyof Item]: Item[P] };
type T11 = { [P in keyof Item]?: Item[P] };
type T12 = { readonly [P in keyof Item]: Item[P] };
type T13 = { readonly [P in keyof Item]?: Item[P] };

type T20 = { [P in keyof Item]: Item[P] | null };
type T21 = { [P in keyof Item]: Array<Item[P]> };

type T30 = { [P in keyof any]: void };
type T31 = { [P in keyof string]: void };
type T32 = { [P in keyof number]: void };
type T33 = { [P in keyof boolean]: void };
type T34 = { [P in keyof undefined]: void };
type T35 = { [P in keyof null]: void };
type T36 = { [P in keyof void]: void };
type T37 = { [P in keyof symbol]: void };
type T38 = { [P in keyof never]: void };

type T40 = { [P in string]: void };
type T43 = { [P in "a" | "b"]: void };
type T44 = { [P in "a" | "b" | "0" | "1"]: void };
type T47 = { [P in string | "a" | "b" | "0" | "1"]: void };

declare function f1<T1>(): { [P in keyof T1]: void };
declare function f2<T1 extends string>(): { [P in keyof T1]: void };
declare function f3<T1 extends number>(): { [P in keyof T1]: void };
declare function f4<T1 extends Number>(): { [P in keyof T1]: void };

let x1 = f1();
let x2 = f2();
let x3 = f3();
let x4 = f4();

//// [mappedTypes1.js]
var x1 = f1();
var x2 = f2();
var x3 = f3();
var x4 = f4();


//// [mappedTypes1.d.ts]
declare type Item = {
    a: string;
    b: number;
    c: boolean;
};
declare type T00 = {
    [P in "x" | "y"]: number;
};
declare type T01 = {
    [P in "x" | "y"]: P;
};
declare type T02 = {
    [P in "a" | "b"]: Item[P];
};
declare type T03 = {
    [P in keyof Item]: Date;
};
declare type T10 = {
    [P in keyof Item]: Item[P];
};
declare type T11 = {
    [P in keyof Item]?: Item[P];
};
declare type T12 = {
    readonly [P in keyof Item]: Item[P];
};
declare type T13 = {
    readonly [P in keyof Item]?: Item[P];
};
declare type T20 = {
    [P in keyof Item]: Item[P] | null;
};
declare type T21 = {
    [P in keyof Item]: Array<Item[P]>;
};
declare type T30 = {
    [P in keyof any]: void;
};
declare type T31 = {
    [P in keyof string]: void;
};
declare type T32 = {
    [P in keyof number]: void;
};
declare type T33 = {
    [P in keyof boolean]: void;
};
declare type T34 = {
    [P in keyof undefined]: void;
};
declare type T35 = {
    [P in keyof null]: void;
};
declare type T36 = {
    [P in keyof void]: void;
};
declare type T37 = {
    [P in keyof symbol]: void;
};
declare type T38 = {
    [P in keyof never]: void;
};
declare type T40 = {
    [P in string]: void;
};
declare type T43 = {
    [P in "a" | "b"]: void;
};
declare type T44 = {
    [P in "a" | "b" | "0" | "1"]: void;
};
declare type T47 = {
    [P in string | "a" | "b" | "0" | "1"]: void;
};
declare function f1<T1>(): {
    [P in keyof T1]: void;
};
declare function f2<T1 extends string>(): {
    [P in keyof T1]: void;
};
declare function f3<T1 extends number>(): {
    [P in keyof T1]: void;
};
declare function f4<T1 extends Number>(): {
    [P in keyof T1]: void;
};
declare let x1: {};
declare let x2: string;
declare let x3: number;
declare let x4: {
    toString: void;
    toFixed: void;
    toExponential: void;
    toPrecision: void;
    valueOf: void;
    toLocaleString: void;
};