Skip to content

Commit 6a21dd6

Browse files
committed
Also test non-strict mode
1 parent f877b23 commit 6a21dd6

17 files changed

+814
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
tests/cases/compiler/destructureCatchClause.ts(26,17): error TS2339: Property 'x' does not exist on type '{}'.
2+
tests/cases/compiler/destructureCatchClause.ts(27,15): error TS2461: Type 'unknown' is not an array type.
3+
tests/cases/compiler/destructureCatchClause.ts(29,17): error TS2339: Property 'a' does not exist on type '{}'.
4+
tests/cases/compiler/destructureCatchClause.ts(30,17): error TS2339: Property 'a' does not exist on type '{}'.
5+
tests/cases/compiler/destructureCatchClause.ts(32,15): error TS2461: Type 'unknown' is not an array type.
6+
tests/cases/compiler/destructureCatchClause.ts(33,15): error TS2461: Type 'unknown' is not an array type.
7+
tests/cases/compiler/destructureCatchClause.ts(35,17): error TS2339: Property 'a' does not exist on type '{}'.
8+
9+
10+
==== tests/cases/compiler/destructureCatchClause.ts (7 errors) ====
11+
// These are okay with useUnknownInCatchVariables=false, but not okay with useUnknownInCatchVariables=true.
12+
try {} catch ({ x }) { x }
13+
try {} catch ([ x ]) { x }
14+
15+
try {} catch ({ a: { x } }) { x }
16+
try {} catch ({ a: [ x ] }) { x }
17+
18+
try {} catch ([{ x }]) { x }
19+
try {} catch ([[ x ]]) { x }
20+
21+
try {} catch ({ a: { b: { c: { x }} }}) { x }
22+
23+
24+
try {} catch ({ x }: any) { x }
25+
try {} catch ([ x ]: any) { x }
26+
27+
try {} catch ({ a: { x } }: any) { x }
28+
try {} catch ({ a: [ x ] }: any) { x }
29+
30+
try {} catch ([{ x }]: any) { x }
31+
try {} catch ([[ x ]]: any) { x }
32+
33+
try {} catch ({ a: { b: { c: { x }} }}: any) { x }
34+
35+
36+
try {} catch ({ x }: unknown) { x }
37+
~
38+
!!! error TS2339: Property 'x' does not exist on type '{}'.
39+
try {} catch ([ x ]: unknown) { x }
40+
~~~~~
41+
!!! error TS2461: Type 'unknown' is not an array type.
42+
43+
try {} catch ({ a: { x } }: unknown) { x }
44+
~
45+
!!! error TS2339: Property 'a' does not exist on type '{}'.
46+
try {} catch ({ a: [ x ] }: unknown) { x }
47+
~
48+
!!! error TS2339: Property 'a' does not exist on type '{}'.
49+
50+
try {} catch ([{ x }]: unknown) { x }
51+
~~~~~~~
52+
!!! error TS2461: Type 'unknown' is not an array type.
53+
try {} catch ([[ x ]]: unknown) { x }
54+
~~~~~~~
55+
!!! error TS2461: Type 'unknown' is not an array type.
56+
57+
try {} catch ({ a: { b: { c: { x }} }}: unknown) { x }
58+
~
59+
!!! error TS2339: Property 'a' does not exist on type '{}'.
60+
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
//// [destructureCatchClause.ts]
2+
// These are okay with useUnknownInCatchVariables=false, but not okay with useUnknownInCatchVariables=true.
3+
try {} catch ({ x }) { x }
4+
try {} catch ([ x ]) { x }
5+
6+
try {} catch ({ a: { x } }) { x }
7+
try {} catch ({ a: [ x ] }) { x }
8+
9+
try {} catch ([{ x }]) { x }
10+
try {} catch ([[ x ]]) { x }
11+
12+
try {} catch ({ a: { b: { c: { x }} }}) { x }
13+
14+
15+
try {} catch ({ x }: any) { x }
16+
try {} catch ([ x ]: any) { x }
17+
18+
try {} catch ({ a: { x } }: any) { x }
19+
try {} catch ({ a: [ x ] }: any) { x }
20+
21+
try {} catch ([{ x }]: any) { x }
22+
try {} catch ([[ x ]]: any) { x }
23+
24+
try {} catch ({ a: { b: { c: { x }} }}: any) { x }
25+
26+
27+
try {} catch ({ x }: unknown) { x }
28+
try {} catch ([ x ]: unknown) { x }
29+
30+
try {} catch ({ a: { x } }: unknown) { x }
31+
try {} catch ({ a: [ x ] }: unknown) { x }
32+
33+
try {} catch ([{ x }]: unknown) { x }
34+
try {} catch ([[ x ]]: unknown) { x }
35+
36+
try {} catch ({ a: { b: { c: { x }} }}: unknown) { x }
37+
38+
39+
//// [destructureCatchClause.js]
40+
// These are okay with useUnknownInCatchVariables=false, but not okay with useUnknownInCatchVariables=true.
41+
try { }
42+
catch (_a) {
43+
var x = _a.x;
44+
x;
45+
}
46+
try { }
47+
catch (_b) {
48+
var x = _b[0];
49+
x;
50+
}
51+
try { }
52+
catch (_c) {
53+
var x = _c.a.x;
54+
x;
55+
}
56+
try { }
57+
catch (_d) {
58+
var x = _d.a[0];
59+
x;
60+
}
61+
try { }
62+
catch (_e) {
63+
var x = _e[0].x;
64+
x;
65+
}
66+
try { }
67+
catch (_f) {
68+
var x = _f[0][0];
69+
x;
70+
}
71+
try { }
72+
catch (_g) {
73+
var x = _g.a.b.c.x;
74+
x;
75+
}
76+
try { }
77+
catch (_h) {
78+
var x = _h.x;
79+
x;
80+
}
81+
try { }
82+
catch (_j) {
83+
var x = _j[0];
84+
x;
85+
}
86+
try { }
87+
catch (_k) {
88+
var x = _k.a.x;
89+
x;
90+
}
91+
try { }
92+
catch (_l) {
93+
var x = _l.a[0];
94+
x;
95+
}
96+
try { }
97+
catch (_m) {
98+
var x = _m[0].x;
99+
x;
100+
}
101+
try { }
102+
catch (_o) {
103+
var x = _o[0][0];
104+
x;
105+
}
106+
try { }
107+
catch (_p) {
108+
var x = _p.a.b.c.x;
109+
x;
110+
}
111+
try { }
112+
catch (_q) {
113+
var x = _q.x;
114+
x;
115+
}
116+
try { }
117+
catch (_r) {
118+
var x = _r[0];
119+
x;
120+
}
121+
try { }
122+
catch (_s) {
123+
var x = _s.a.x;
124+
x;
125+
}
126+
try { }
127+
catch (_t) {
128+
var x = _t.a[0];
129+
x;
130+
}
131+
try { }
132+
catch (_u) {
133+
var x = _u[0].x;
134+
x;
135+
}
136+
try { }
137+
catch (_v) {
138+
var x = _v[0][0];
139+
x;
140+
}
141+
try { }
142+
catch (_w) {
143+
var x = _w.a.b.c.x;
144+
x;
145+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
tests/cases/compiler/destructureCatchClause.ts(2,17): error TS2339: Property 'x' does not exist on type '{}'.
2+
tests/cases/compiler/destructureCatchClause.ts(3,15): error TS2461: Type 'unknown' is not an array type.
3+
tests/cases/compiler/destructureCatchClause.ts(5,17): error TS2339: Property 'a' does not exist on type '{}'.
4+
tests/cases/compiler/destructureCatchClause.ts(6,17): error TS2339: Property 'a' does not exist on type '{}'.
5+
tests/cases/compiler/destructureCatchClause.ts(8,15): error TS2461: Type 'unknown' is not an array type.
6+
tests/cases/compiler/destructureCatchClause.ts(9,15): error TS2461: Type 'unknown' is not an array type.
7+
tests/cases/compiler/destructureCatchClause.ts(11,17): error TS2339: Property 'a' does not exist on type '{}'.
8+
tests/cases/compiler/destructureCatchClause.ts(26,17): error TS2339: Property 'x' does not exist on type '{}'.
9+
tests/cases/compiler/destructureCatchClause.ts(27,15): error TS2461: Type 'unknown' is not an array type.
10+
tests/cases/compiler/destructureCatchClause.ts(29,17): error TS2339: Property 'a' does not exist on type '{}'.
11+
tests/cases/compiler/destructureCatchClause.ts(30,17): error TS2339: Property 'a' does not exist on type '{}'.
12+
tests/cases/compiler/destructureCatchClause.ts(32,15): error TS2461: Type 'unknown' is not an array type.
13+
tests/cases/compiler/destructureCatchClause.ts(33,15): error TS2461: Type 'unknown' is not an array type.
14+
tests/cases/compiler/destructureCatchClause.ts(35,17): error TS2339: Property 'a' does not exist on type '{}'.
15+
16+
17+
==== tests/cases/compiler/destructureCatchClause.ts (14 errors) ====
18+
// These are okay with useUnknownInCatchVariables=false, but not okay with useUnknownInCatchVariables=true.
19+
try {} catch ({ x }) { x }
20+
~
21+
!!! error TS2339: Property 'x' does not exist on type '{}'.
22+
try {} catch ([ x ]) { x }
23+
~~~~~
24+
!!! error TS2461: Type 'unknown' is not an array type.
25+
26+
try {} catch ({ a: { x } }) { x }
27+
~
28+
!!! error TS2339: Property 'a' does not exist on type '{}'.
29+
try {} catch ({ a: [ x ] }) { x }
30+
~
31+
!!! error TS2339: Property 'a' does not exist on type '{}'.
32+
33+
try {} catch ([{ x }]) { x }
34+
~~~~~~~
35+
!!! error TS2461: Type 'unknown' is not an array type.
36+
try {} catch ([[ x ]]) { x }
37+
~~~~~~~
38+
!!! error TS2461: Type 'unknown' is not an array type.
39+
40+
try {} catch ({ a: { b: { c: { x }} }}) { x }
41+
~
42+
!!! error TS2339: Property 'a' does not exist on type '{}'.
43+
44+
45+
try {} catch ({ x }: any) { x }
46+
try {} catch ([ x ]: any) { x }
47+
48+
try {} catch ({ a: { x } }: any) { x }
49+
try {} catch ({ a: [ x ] }: any) { x }
50+
51+
try {} catch ([{ x }]: any) { x }
52+
try {} catch ([[ x ]]: any) { x }
53+
54+
try {} catch ({ a: { b: { c: { x }} }}: any) { x }
55+
56+
57+
try {} catch ({ x }: unknown) { x }
58+
~
59+
!!! error TS2339: Property 'x' does not exist on type '{}'.
60+
try {} catch ([ x ]: unknown) { x }
61+
~~~~~
62+
!!! error TS2461: Type 'unknown' is not an array type.
63+
64+
try {} catch ({ a: { x } }: unknown) { x }
65+
~
66+
!!! error TS2339: Property 'a' does not exist on type '{}'.
67+
try {} catch ({ a: [ x ] }: unknown) { x }
68+
~
69+
!!! error TS2339: Property 'a' does not exist on type '{}'.
70+
71+
try {} catch ([{ x }]: unknown) { x }
72+
~~~~~~~
73+
!!! error TS2461: Type 'unknown' is not an array type.
74+
try {} catch ([[ x ]]: unknown) { x }
75+
~~~~~~~
76+
!!! error TS2461: Type 'unknown' is not an array type.
77+
78+
try {} catch ({ a: { b: { c: { x }} }}: unknown) { x }
79+
~
80+
!!! error TS2339: Property 'a' does not exist on type '{}'.
81+

0 commit comments

Comments
 (0)