-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwtf.ts
44 lines (34 loc) · 854 Bytes
/
wtf.ts
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
type MyObject = {
[index:string]: MyObject | Function | "wtf"
}
let myObj: MyObject;
// compiles
myObj = {
name: "wtf",
};
// compiles - note the nested key is `notName:`, instead of `name:`
myObj = {
wrapper: {
notName: "wtf",
},
};
// as soon as I change the nested key to `name:`, it fails to compile:
/*
Type '{ name: string; }' is not assignable to type 'Function | MyObject | "wtf"'.
Type '{ name: string; }' is not assignable to type '"wtf"'
*/
myObj = {
wrapper: {
name: "wtf",
},
};
// Other weirdness, if I remove `Function` from the union, it compiles:
type MyObjectNoFunction = {
[index:string]: MyObjectNoFunction | "wtf"
}
let myObjNoFn: MyObjectNoFunction = {
wrapper: {
name: "wtf"
}
};
// More weirdness, if I don't include es6 in my tsconfig, everything compiles