forked from microsoft/TypeScript
/
objectRestParameter.types
104 lines (94 loc) · 3.07 KB
/
objectRestParameter.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
=== tests/cases/conformance/types/rest/objectRestParameter.ts ===
function cloneAgain({ a, ...clone }: { a: number, b: string }): void {
>cloneAgain : ({ a, ...clone }: { a: number; b: string;}) => void
>a : number
>clone : { b: string; }
>a : number
>b : string
}
declare function suddenly(f: (a: { x: { z, ka }, y: string }) => void);
>suddenly : (f: (a: { x: { z; ka; }; y: string;}) => void) => any
>f : (a: { x: { z; ka; }; y: string;}) => void
>a : { x: { z; ka;}; y: string; }
>x : { z: any; ka: any; }
>z : any
>ka : any
>y : string
suddenly(({ x: a, ...rest }) => rest.y);
>suddenly(({ x: a, ...rest }) => rest.y) : any
>suddenly : (f: (a: { x: { z: any; ka: any; }; y: string; }) => void) => any
>({ x: a, ...rest }) => rest.y : ({ x: a, ...rest }: { x: { z: any; ka: any; }; y: string; }) => string
>x : any
>a : { z: any; ka: any; }
>rest : { y: string; }
>rest.y : string
>rest : { y: string; }
>y : string
suddenly(({ x: { z = 12, ...nested }, ...rest } = { x: { z: 1, ka: 1 }, y: 'noo' }) => rest.y + nested.ka);
>suddenly(({ x: { z = 12, ...nested }, ...rest } = { x: { z: 1, ka: 1 }, y: 'noo' }) => rest.y + nested.ka) : any
>suddenly : (f: (a: { x: { z: any; ka: any; }; y: string; }) => void) => any
>({ x: { z = 12, ...nested }, ...rest } = { x: { z: 1, ka: 1 }, y: 'noo' }) => rest.y + nested.ka : ({ x: { z, ...nested }, ...rest }?: { x: { z: any; ka: any; }; y: string; }) => string
>x : any
>z : any
>12 : 12
>nested : { ka: any; }
>rest : { y: string; }
>{ x: { z: 1, ka: 1 }, y: 'noo' } : { x: { z: number; ka: number; }; y: string; }
>x : { z: number; ka: number; }
>{ z: 1, ka: 1 } : { z: number; ka: number; }
>z : number
>1 : 1
>ka : number
>1 : 1
>y : string
>'noo' : "noo"
>rest.y + nested.ka : string
>rest.y : string
>rest : { y: string; }
>y : string
>nested.ka : any
>nested : { ka: any; }
>ka : any
class C {
>C : C
m({ a, ...clone }: { a: number, b: string}): void {
>m : ({ a, ...clone }: { a: number; b: string;}) => void
>a : number
>clone : { b: string; }
>a : number
>b : string
// actually, never mind, don't clone
}
set p({ a, ...clone }: { a: number, b: string}) {
>p : { a: number; b: string; }
>a : number
>clone : { b: string; }
>a : number
>b : string
// actually, never mind, don't clone
}
}
function foobar({ bar={}, ...opts }: any = {}) {
>foobar : ({ bar, ...opts }?: any) => void
>bar : any
>{} : {}
>opts : any
>{} : {}
}
foobar();
>foobar() : void
>foobar : ({ bar, ...opts }?: any) => void
foobar({ baz: 'hello' });
>foobar({ baz: 'hello' }) : void
>foobar : ({ bar, ...opts }?: any) => void
>{ baz: 'hello' } : { baz: string; }
>baz : string
>'hello' : "hello"
foobar({ bar: { greeting: 'hello' } });
>foobar({ bar: { greeting: 'hello' } }) : void
>foobar : ({ bar, ...opts }?: any) => void
>{ bar: { greeting: 'hello' } } : { bar: { greeting: string; }; }
>bar : { greeting: string; }
>{ greeting: 'hello' } : { greeting: string; }
>greeting : string
>'hello' : "hello"