File tree Expand file tree Collapse file tree
cases/conformance/statements/tryStatements Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- ==== tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts (2 errors) ====
1+ ==== tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts (6 errors) ====
22 function fn() {
33 try {
44 } catch { // syntax error, missing '(x)'
1010 ~~~~~
1111!!! A 'catch' clause must be preceded by a 'try' statement.
1212
13- finally{ } // error missing try
13+ finally{ } // potential error; can be absorbed by the 'catch'
14+ }
15+
16+ function fn2() {
17+ finally { } // error missing try
18+ ~~~~~~~
19+ !!! A 'finally' block must be preceded by a 'try' statement.
20+ catch (x) { } // error missing try
21+ ~~~~~
22+ !!! A 'catch' clause must be preceded by a 'try' statement.
23+
24+ // no error
25+ try {
26+ }
27+ finally {
28+ }
29+
30+ // error missing try
31+ finally {
32+ ~~~~~~~
33+ !!! A 'finally' block must be preceded by a 'try' statement.
34+ }
35+
36+ // error missing try
37+ catch (x) {
38+ ~~~~~
39+ !!! A 'catch' clause must be preceded by a 'try' statement.
40+ }
1441 }
Original file line number Diff line number Diff line change @@ -5,5 +5,24 @@ function fn() {
55
66 catch ( x ) { } // error missing try
77
8- finally { } // error missing try
8+ finally { } // potential error; can be absorbed by the 'catch'
9+ }
10+
11+ function fn2 ( ) {
12+ finally { } // error missing try
13+ catch ( x ) { } // error missing try
14+
15+ // no error
16+ try {
17+ }
18+ finally {
19+ }
20+
21+ // error missing try
22+ finally {
23+ }
24+
25+ // error missing try
26+ catch ( x ) {
27+ }
928}
You can’t perform that action at this time.
0 commit comments