@@ -100,17 +100,22 @@ class Foo {
100
100
'const x: Set<string> = new Set();' ,
101
101
'const x: Set<string> = new Set<string>();' ,
102
102
'const [x] = [1];' ,
103
+ 'const [x, y] = [1, 2] as number[];' ,
103
104
'const [x, ...y] = [1, 2, 3, 4, 5];' ,
104
105
'const [x, ...y] = [1];' ,
106
+ 'const [{ ...x }] = [{ x: 1 }] as [{ x: any }];' ,
105
107
'function foo(x = 1) {}' ,
106
108
'function foo([x] = [1]) {}' ,
107
109
'function foo([x, ...y] = [1, 2, 3, 4, 5]) {}' ,
108
110
'function foo([x, ...y] = [1]) {}' ,
109
111
// this is not checked, because there's no annotation to compare it with
110
112
'const x = new Set<any>();' ,
111
113
'const x = { y: 1 };' ,
114
+ 'const x = { y = 1 };' ,
115
+ 'const x = { y(); };' ,
112
116
'const x: { y: number } = { y: 1 };' ,
113
117
'const x = [...[1, 2, 3]];' ,
118
+ 'const [{ [`x${1}`]: x }] = [{ [`x`]: 1 }] as [{ [`x`]: any }];' ,
114
119
{
115
120
code : `
116
121
type Props = { a: string };
@@ -119,15 +124,23 @@ declare function Foo(props: Props): never;
119
124
` ,
120
125
filename : 'react.tsx' ,
121
126
} ,
122
- `
123
- const x: unknown = y as any;
124
- ` ,
125
- `
126
- const x: unknown[] = y as any[];
127
- ` ,
128
- `
129
- const x: Set<unknown> = y as Set<any>;
130
- ` ,
127
+ {
128
+ code : `
129
+ declare function Foo(props: { a: string }): never;
130
+ <Foo a="foo" />;
131
+ ` ,
132
+ filename : 'react.tsx' ,
133
+ } ,
134
+ {
135
+ code : `
136
+ declare function Foo(props: { a: string }): never;
137
+ <Foo a={} />;
138
+ ` ,
139
+ filename : 'react.tsx' ,
140
+ } ,
141
+ 'const x: unknown = y as any;' ,
142
+ 'const x: unknown[] = y as any[];' ,
143
+ 'const x: Set<unknown> = y as Set<any>;' ,
131
144
] ,
132
145
invalid : [
133
146
...batchedSingleLineTests ( {
@@ -238,6 +251,8 @@ const x: Set<Set<Set<string>>> = new Set<Set<Set<any>>>();
238
251
[ '[[[[x]]]] = [[[[1 as any]]]]' , 5 , 6 ] ,
239
252
[ '[[[[x]]]] = [1 as any]' , 2 , 9 , true ] ,
240
253
[ '[{x}] = [{x: 1}] as [{x: any}]' , 3 , 4 ] ,
254
+ [ '[{["x"]: x}] = [{["x"]: 1}] as [{["x"]: any}]' , 10 , 11 ] ,
255
+ [ '[{[`x`]: x}] = [{[`x`]: 1}] as [{[`x`]: any}]' , 10 , 11 ] ,
241
256
] ) ,
242
257
{
243
258
// TS treats the assignment pattern weirdly in this case
0 commit comments