-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make catch clause checking consistent with variable declarations (#52240
- Loading branch information
1 parent
ecaf6d9
commit b7f619d
Showing
30 changed files
with
1,719 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...eference/destructureCatchClause(strict=false,useunknownincatchvariables=false).errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
tests/cases/compiler/destructureCatchClause.ts(26,17): error TS2339: Property 'x' does not exist on type '{}'. | ||
tests/cases/compiler/destructureCatchClause.ts(27,15): error TS2461: Type 'unknown' is not an array type. | ||
tests/cases/compiler/destructureCatchClause.ts(29,17): error TS2339: Property 'a' does not exist on type '{}'. | ||
tests/cases/compiler/destructureCatchClause.ts(30,17): error TS2339: Property 'a' does not exist on type '{}'. | ||
tests/cases/compiler/destructureCatchClause.ts(32,15): error TS2461: Type 'unknown' is not an array type. | ||
tests/cases/compiler/destructureCatchClause.ts(33,15): error TS2461: Type 'unknown' is not an array type. | ||
tests/cases/compiler/destructureCatchClause.ts(35,17): error TS2339: Property 'a' does not exist on type '{}'. | ||
|
||
|
||
==== tests/cases/compiler/destructureCatchClause.ts (7 errors) ==== | ||
// These are okay with useUnknownInCatchVariables=false, but not okay with useUnknownInCatchVariables=true. | ||
try {} catch ({ x }) { x } | ||
try {} catch ([ x ]) { x } | ||
|
||
try {} catch ({ a: { x } }) { x } | ||
try {} catch ({ a: [ x ] }) { x } | ||
|
||
try {} catch ([{ x }]) { x } | ||
try {} catch ([[ x ]]) { x } | ||
|
||
try {} catch ({ a: { b: { c: { x }} }}) { x } | ||
|
||
|
||
try {} catch ({ x }: any) { x } | ||
try {} catch ([ x ]: any) { x } | ||
|
||
try {} catch ({ a: { x } }: any) { x } | ||
try {} catch ({ a: [ x ] }: any) { x } | ||
|
||
try {} catch ([{ x }]: any) { x } | ||
try {} catch ([[ x ]]: any) { x } | ||
|
||
try {} catch ({ a: { b: { c: { x }} }}: any) { x } | ||
|
||
|
||
try {} catch ({ x }: unknown) { x } | ||
~ | ||
!!! error TS2339: Property 'x' does not exist on type '{}'. | ||
try {} catch ([ x ]: unknown) { x } | ||
~~~~~ | ||
!!! error TS2461: Type 'unknown' is not an array type. | ||
|
||
try {} catch ({ a: { x } }: unknown) { x } | ||
~ | ||
!!! error TS2339: Property 'a' does not exist on type '{}'. | ||
try {} catch ({ a: [ x ] }: unknown) { x } | ||
~ | ||
!!! error TS2339: Property 'a' does not exist on type '{}'. | ||
|
||
try {} catch ([{ x }]: unknown) { x } | ||
~~~~~~~ | ||
!!! error TS2461: Type 'unknown' is not an array type. | ||
try {} catch ([[ x ]]: unknown) { x } | ||
~~~~~~~ | ||
!!! error TS2461: Type 'unknown' is not an array type. | ||
|
||
try {} catch ({ a: { b: { c: { x }} }}: unknown) { x } | ||
~ | ||
!!! error TS2339: Property 'a' does not exist on type '{}'. | ||
|
145 changes: 145 additions & 0 deletions
145
...elines/reference/destructureCatchClause(strict=false,useunknownincatchvariables=false).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
//// [destructureCatchClause.ts] | ||
// These are okay with useUnknownInCatchVariables=false, but not okay with useUnknownInCatchVariables=true. | ||
try {} catch ({ x }) { x } | ||
try {} catch ([ x ]) { x } | ||
|
||
try {} catch ({ a: { x } }) { x } | ||
try {} catch ({ a: [ x ] }) { x } | ||
|
||
try {} catch ([{ x }]) { x } | ||
try {} catch ([[ x ]]) { x } | ||
|
||
try {} catch ({ a: { b: { c: { x }} }}) { x } | ||
|
||
|
||
try {} catch ({ x }: any) { x } | ||
try {} catch ([ x ]: any) { x } | ||
|
||
try {} catch ({ a: { x } }: any) { x } | ||
try {} catch ({ a: [ x ] }: any) { x } | ||
|
||
try {} catch ([{ x }]: any) { x } | ||
try {} catch ([[ x ]]: any) { x } | ||
|
||
try {} catch ({ a: { b: { c: { x }} }}: any) { x } | ||
|
||
|
||
try {} catch ({ x }: unknown) { x } | ||
try {} catch ([ x ]: unknown) { x } | ||
|
||
try {} catch ({ a: { x } }: unknown) { x } | ||
try {} catch ({ a: [ x ] }: unknown) { x } | ||
|
||
try {} catch ([{ x }]: unknown) { x } | ||
try {} catch ([[ x ]]: unknown) { x } | ||
|
||
try {} catch ({ a: { b: { c: { x }} }}: unknown) { x } | ||
|
||
|
||
//// [destructureCatchClause.js] | ||
// These are okay with useUnknownInCatchVariables=false, but not okay with useUnknownInCatchVariables=true. | ||
try { } | ||
catch (_a) { | ||
var x = _a.x; | ||
x; | ||
} | ||
try { } | ||
catch (_b) { | ||
var x = _b[0]; | ||
x; | ||
} | ||
try { } | ||
catch (_c) { | ||
var x = _c.a.x; | ||
x; | ||
} | ||
try { } | ||
catch (_d) { | ||
var x = _d.a[0]; | ||
x; | ||
} | ||
try { } | ||
catch (_e) { | ||
var x = _e[0].x; | ||
x; | ||
} | ||
try { } | ||
catch (_f) { | ||
var x = _f[0][0]; | ||
x; | ||
} | ||
try { } | ||
catch (_g) { | ||
var x = _g.a.b.c.x; | ||
x; | ||
} | ||
try { } | ||
catch (_h) { | ||
var x = _h.x; | ||
x; | ||
} | ||
try { } | ||
catch (_j) { | ||
var x = _j[0]; | ||
x; | ||
} | ||
try { } | ||
catch (_k) { | ||
var x = _k.a.x; | ||
x; | ||
} | ||
try { } | ||
catch (_l) { | ||
var x = _l.a[0]; | ||
x; | ||
} | ||
try { } | ||
catch (_m) { | ||
var x = _m[0].x; | ||
x; | ||
} | ||
try { } | ||
catch (_o) { | ||
var x = _o[0][0]; | ||
x; | ||
} | ||
try { } | ||
catch (_p) { | ||
var x = _p.a.b.c.x; | ||
x; | ||
} | ||
try { } | ||
catch (_q) { | ||
var x = _q.x; | ||
x; | ||
} | ||
try { } | ||
catch (_r) { | ||
var x = _r[0]; | ||
x; | ||
} | ||
try { } | ||
catch (_s) { | ||
var x = _s.a.x; | ||
x; | ||
} | ||
try { } | ||
catch (_t) { | ||
var x = _t.a[0]; | ||
x; | ||
} | ||
try { } | ||
catch (_u) { | ||
var x = _u[0].x; | ||
x; | ||
} | ||
try { } | ||
catch (_v) { | ||
var x = _v[0][0]; | ||
x; | ||
} | ||
try { } | ||
catch (_w) { | ||
var x = _w.a.b.c.x; | ||
x; | ||
} |
Oops, something went wrong.