forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinferTupleFromBindingPattern(nouncheckedindexedaccess=false).types
More file actions
54 lines (45 loc) · 1.35 KB
/
inferTupleFromBindingPattern(nouncheckedindexedaccess=false).types
File metadata and controls
54 lines (45 loc) · 1.35 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
//// [tests/cases/compiler/inferTupleFromBindingPattern.ts] ////
=== inferTupleFromBindingPattern.ts ===
declare function f<T>(cb: () => T): T;
>f : <T>(cb: () => T) => T
>cb : () => T
const [e1, e2, e3] = f(() => [1, "hi", true]);
>e1 : number
>e2 : string
>e3 : boolean
>f(() => [1, "hi", true]) : [number, string, boolean]
>f : <T>(cb: () => T) => T
>() => [1, "hi", true] : () => [number, string, boolean]
>[1, "hi", true] : [number, string, true]
>1 : 1
>"hi" : "hi"
>true : true
// repro from #42969
declare const f2: <T extends string[]>(t: T) => [T, string[]];
>f2 : <T extends string[]>(t: T) => [T, string[]]
>t : T
const [[f2e1]] = f2(['1']);
>f2e1 : string
>f2(['1']) : [[string], string[]]
>f2 : <T extends string[]>(t: T) => [T, string[]]
>['1'] : [string]
>'1' : "1"
f2e1.toLowerCase();
>f2e1.toLowerCase() : string
>f2e1.toLowerCase : () => string
>f2e1 : string
>toLowerCase : () => string
declare const f3: <T extends string[]>(t: T) => [[T, string[]]];
>f3 : <T extends string[]>(t: T) => [[T, string[]]]
>t : T
const [[[f3e1]]] = f3(['1']);
>f3e1 : string
>f3(['1']) : [[[string], string[]]]
>f3 : <T extends string[]>(t: T) => [[T, string[]]]
>['1'] : [string]
>'1' : "1"
f3e1.toLowerCase();
>f3e1.toLowerCase() : string
>f3e1.toLowerCase : () => string
>f3e1 : string
>toLowerCase : () => string