/
recursiveTypeRelations.types
111 lines (91 loc) · 5 KB
/
recursiveTypeRelations.types
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
=== tests/cases/compiler/recursiveTypeRelations.ts ===
// Repro from #14896
type Attributes<Keys extends keyof any> = {
>Attributes : Attributes<Keys>
[Key in Keys]: string;
}
class Query<A extends Attributes<keyof A>> {
>Query : Query<A>
multiply<B extends Attributes<keyof B>>(x: B): Query<A & B>;
>multiply : <B extends Attributes<keyof B>>(x: B) => Query<A & B>
>x : B
}
// Repro from #14940
type ClassName<S> = keyof S;
>ClassName : keyof S
type ClassNameMap<S> = { [K in keyof S]?: boolean }
>ClassNameMap : ClassNameMap<S>
type ClassNameObjectMap<S> = object & ClassNameMap<S>;
>ClassNameObjectMap : ClassNameObjectMap<S>
type ClassNameArg<S> = ClassName<S> | ClassNameObjectMap<S>;
>ClassNameArg : ClassNameArg<S>
export function css<S extends { [K in keyof S]: string }>(styles: S, ...classNames: ClassNameArg<S>[]): string {
>css : <S extends { [K in keyof S]: string; }>(styles: S, ...classNames: ClassNameArg<S>[]) => string
>styles : S
>classNames : ClassNameArg<S>[]
const args = classNames.map(arg => {
>args : any[]
>classNames.map(arg => { if (arg == null) { return null; } if (typeof arg == "string") { return styles[arg]; } if (typeof arg == "object") { return Object.keys(arg).reduce<ClassNameObject>((obj: ClassNameObject, key: keyof S) => { const exportedClassName = styles[key]; obj[exportedClassName] = (arg as ClassNameMap<S>)[key]; return obj; }, {}); } }) : any[]
>classNames.map : <U>(callbackfn: (value: ClassNameArg<S>, index: number, array: ClassNameArg<S>[]) => U, thisArg?: any) => U[]
>classNames : ClassNameArg<S>[]
>map : <U>(callbackfn: (value: ClassNameArg<S>, index: number, array: ClassNameArg<S>[]) => U, thisArg?: any) => U[]
>arg => { if (arg == null) { return null; } if (typeof arg == "string") { return styles[arg]; } if (typeof arg == "object") { return Object.keys(arg).reduce<ClassNameObject>((obj: ClassNameObject, key: keyof S) => { const exportedClassName = styles[key]; obj[exportedClassName] = (arg as ClassNameMap<S>)[key]; return obj; }, {}); } } : (arg: ClassNameArg<S>) => any
>arg : ClassNameArg<S>
if (arg == null) {
>arg == null : boolean
>arg : ClassNameArg<S>
>null : null
return null;
>null : null
}
if (typeof arg == "string") {
>typeof arg == "string" : boolean
>typeof arg : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
>arg : ClassNameArg<S>
>"string" : "string"
return styles[arg];
>styles[arg] : S[keyof S & string]
>styles : S
>arg : keyof S & string
}
if (typeof arg == "object") {
>typeof arg == "object" : boolean
>typeof arg : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
>arg : ClassNameArg<S>
>"object" : "object"
return Object.keys(arg).reduce<ClassNameObject>((obj: ClassNameObject, key: keyof S) => {
>Object.keys(arg).reduce<ClassNameObject>((obj: ClassNameObject, key: keyof S) => { const exportedClassName = styles[key]; obj[exportedClassName] = (arg as ClassNameMap<S>)[key]; return obj; }, {}) : any
>Object.keys(arg).reduce : { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; <U>(callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; }
>Object.keys(arg) : string[]
>Object.keys : (o: object) => string[]
>Object : ObjectConstructor
>keys : (o: object) => string[]
>arg : ClassNameObjectMap<S>
>reduce : { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; <U>(callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; }
>(obj: ClassNameObject, key: keyof S) => { const exportedClassName = styles[key]; obj[exportedClassName] = (arg as ClassNameMap<S>)[key]; return obj; } : (obj: any, key: keyof S) => any
>obj : any
>key : keyof S
const exportedClassName = styles[key];
>exportedClassName : S[keyof S]
>styles[key] : S[keyof S]
>styles : S
>key : keyof S
obj[exportedClassName] = (arg as ClassNameMap<S>)[key];
>obj[exportedClassName] = (arg as ClassNameMap<S>)[key] : ClassNameMap<S>[keyof S]
>obj[exportedClassName] : any
>obj : any
>exportedClassName : S[keyof S]
>(arg as ClassNameMap<S>)[key] : ClassNameMap<S>[keyof S]
>(arg as ClassNameMap<S>) : ClassNameMap<S>
>arg as ClassNameMap<S> : ClassNameMap<S>
>arg : ClassNameObjectMap<S>
>key : keyof S
return obj;
>obj : any
}, {});
>{} : {}
}
});
return "";
>"" : ""
}