diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5210b89eb1f..c97020c1142 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1807,7 +1807,7 @@ namespace ts { export interface CatchClause extends Node { kind: SyntaxKind.CatchClause; - parent: TryStatement; + parent?: TryStatement; // We parse missing try statements variableDeclaration?: VariableDeclaration; block: Block; } diff --git a/tests/baselines/reference/invalidTryStatements2.errors.txt b/tests/baselines/reference/invalidTryStatements2.errors.txt index e1d285b8c88..38c30fb32ab 100644 --- a/tests/baselines/reference/invalidTryStatements2.errors.txt +++ b/tests/baselines/reference/invalidTryStatements2.errors.txt @@ -1,16 +1,12 @@ -tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(6,5): error TS1005: 'try' expected. -tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(12,5): error TS1005: 'try' expected. -tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(13,5): error TS1005: 'try' expected. +tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(2,5): error TS1005: 'try' expected. +tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(8,5): error TS1005: 'try' expected. +tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(9,5): error TS1005: 'try' expected. +tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(18,5): error TS1005: 'try' expected. tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(22,5): error TS1005: 'try' expected. -tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(26,5): error TS1005: 'try' expected. ==== tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts (5 errors) ==== function fn() { - try { - } catch { // syntax error, missing '(x)' - } - catch(x) { } // error missing try ~~~~~ !!! error TS1005: 'try' expected. diff --git a/tests/baselines/reference/invalidTryStatements2.js b/tests/baselines/reference/invalidTryStatements2.js index 44fb6bb7071..45b150b4094 100644 --- a/tests/baselines/reference/invalidTryStatements2.js +++ b/tests/baselines/reference/invalidTryStatements2.js @@ -1,9 +1,5 @@ //// [invalidTryStatements2.ts] function fn() { - try { - } catch { // syntax error, missing '(x)' - } - catch(x) { } // error missing try finally{ } // potential error; can be absorbed by the 'catch' @@ -30,10 +26,6 @@ function fn2() { //// [invalidTryStatements2.js] function fn() { - try { - } - catch (_ignoredCatchParameter) { - } try { } catch (x) { } // error missing try diff --git a/tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts b/tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts index 6937e509845..205d6f3f193 100644 --- a/tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts +++ b/tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts @@ -1,8 +1,4 @@ function fn() { - try { - } catch { // syntax error, missing '(x)' - } - catch(x) { } // error missing try finally{ } // potential error; can be absorbed by the 'catch'