-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathreverseMappedThisTypeInference.js
More file actions
76 lines (68 loc) · 1.45 KB
/
reverseMappedThisTypeInference.js
File metadata and controls
76 lines (68 loc) · 1.45 KB
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
//// [tests/cases/compiler/reverseMappedThisTypeInference.ts] ////
//// [reverseMappedThisTypeInference.ts]
// Issue #62779: Type parameter leak caused by `this` and reverse mapped type
declare function testReverseMapped<T extends Record<string, unknown>>(obj: {
[K in keyof T]: () => T[K];
}): T;
const obj = testReverseMapped({
a() {
return 0;
},
b() {
return this.a();
},
});
// Intersection with mapped type
declare function testReverseMapped2<T extends Record<string, unknown>, T2>(
obj: T2 & {
[K in keyof T]: () => T[K];
},
): T;
const obj2 = testReverseMapped2({
a() {
return 0;
},
b() {
return this.a();
},
});
// Union with mapped type
declare function testReverseMapped3<T extends Record<string, unknown>, T2>(
obj: T2 | {
[K in keyof T]: () => T[K];
},
): T;
const obj3 = testReverseMapped3({
a() {
return 0;
},
b() {
return this.a();
},
});
//// [reverseMappedThisTypeInference.js]
"use strict";
var obj = testReverseMapped({
a: function () {
return 0;
},
b: function () {
return this.a();
},
});
var obj2 = testReverseMapped2({
a: function () {
return 0;
},
b: function () {
return this.a();
},
});
var obj3 = testReverseMapped3({
a: function () {
return 0;
},
b: function () {
return this.a();
},
});