From a2eabe1f4b7b6a46bab1a8d840763ddb6f878f54 Mon Sep 17 00:00:00 2001 From: DonIsaac <22823424+DonIsaac@users.noreply.github.com> Date: Thu, 18 Jul 2024 16:09:25 +0000 Subject: [PATCH] refactor(parser): use error codes for ts diagnostics (#4335) Part of #4333 --- crates/oxc_diagnostics/src/lib.rs | 8 ++ crates/oxc_parser/src/diagnostics.rs | 48 +++++++----- tasks/coverage/parser_babel.snap | 48 ++++++------ tasks/coverage/parser_test262.snap | 28 +++---- tasks/coverage/parser_typescript.snap | 102 +++++++++++++------------- 5 files changed, 125 insertions(+), 109 deletions(-) diff --git a/crates/oxc_diagnostics/src/lib.rs b/crates/oxc_diagnostics/src/lib.rs index 5cd94f6634adb..cfe5b6655a8bb 100644 --- a/crates/oxc_diagnostics/src/lib.rs +++ b/crates/oxc_diagnostics/src/lib.rs @@ -47,6 +47,11 @@ pub struct OxcCode { pub scope: Option>, pub number: Option>, } +impl OxcCode { + pub fn is_some(&self) -> bool { + self.scope.is_some() || self.number.is_some() + } +} impl fmt::Display for OxcCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -70,6 +75,9 @@ pub struct OxcDiagnosticInner { impl fmt::Display for OxcDiagnostic { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result { + if self.code.is_some() { + write!(f, "{}: ", &self.code)?; + } write!(f, "{}", &self.message) } } diff --git a/crates/oxc_parser/src/diagnostics.rs b/crates/oxc_parser/src/diagnostics.rs index e17af24b834da..15816e2e02a83 100644 --- a/crates/oxc_parser/src/diagnostics.rs +++ b/crates/oxc_parser/src/diagnostics.rs @@ -1,8 +1,19 @@ +use std::borrow::Cow; + use oxc_diagnostics::OxcDiagnostic; use oxc_span::Span; use crate::modifiers::Modifier; +#[inline] +fn ts_error(code: C, message: M) -> OxcDiagnostic +where + C: Into>, + M: Into>, +{ + OxcDiagnostic::error(message).with_error_code("TS", code) +} + #[cold] pub fn redeclaration(x0: &str, declare_span: Span, redeclare_span: Span) -> OxcDiagnostic { OxcDiagnostic::error(format!("Identifier `{x0}` has already been declared")).with_labels([ @@ -305,13 +316,12 @@ pub fn optional_chain_tagged_template(span0: Span) -> OxcDiagnostic { #[cold] pub fn ts_constructor_this_parameter(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::error("TS2681: A constructor cannot have a `this` parameter.").with_label(span0) + ts_error("2681", "A constructor cannot have a `this` parameter.").with_label(span0) } #[cold] pub fn ts_arrow_function_this_parameter(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::error("TS2730: An arrow function cannot have a `this` parameter.") - .with_label(span0) + ts_error("2730", "An arrow function cannot have a `this` parameter.").with_label(span0) } #[cold] @@ -335,19 +345,20 @@ pub fn expect_catch_finally(span0: Span) -> OxcDiagnostic { #[cold] pub fn a_set_accessor_cannot_have_a_return_type_annotation(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::error("TS1095: A 'set' accessor cannot have a return type annotation") - .with_label(span0) + ts_error("1095", " A 'set' accessor cannot have a return type annotation.").with_label(span0) } #[cold] pub fn return_statement_only_in_function_body(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::error("TS1108: A 'return' statement can only be used within a function body") + ts_error("1108", "A 'return' statement can only be used within a function body.") .with_label(span0) } #[cold] pub fn jsx_expressions_may_not_use_the_comma_operator(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::error("TS18007: JSX expressions may not use the comma operator.") + // OxcDiagnostic::error("TS18007: JSX expressions may not use the comma + // operator.") + ts_error("18007", "JSX expressions may not use the comma operator") .with_help("Did you mean to write an array?") .with_label(span0) } @@ -389,9 +400,10 @@ pub fn using_declarations_must_be_initialized(span0: Span) -> OxcDiagnostic { OxcDiagnostic::error("Using declarations must have an initializer.").with_label(span0) } +/// TS(1093) #[cold] pub fn static_constructor(span0: Span) -> OxcDiagnostic { - OxcDiagnostic::error("TS1089: `static` modifier cannot appear on a constructor declaration.") + ts_error("1089", "`static` modifier cannot appear on a constructor declaration.") .with_label(span0) } @@ -412,7 +424,8 @@ pub fn modifier_cannot_be_used_here(modifier: &Modifier) -> OxcDiagnostic { /// TS(1030) #[cold] pub fn modifier_already_seen(modifier: &Modifier) -> OxcDiagnostic { - OxcDiagnostic::error(format!("TS1030: '{}' modifier already seen.", modifier.kind)) + // OxcDiagnostic::error(format!("TS1030: '{}' modifier already seen.", modifier.kind)) + ts_error("1030", format!("{}' modifier already seen.", modifier.kind)) .with_label(modifier.span) .with_help("Remove the duplicate modifier.") } @@ -420,24 +433,19 @@ pub fn modifier_already_seen(modifier: &Modifier) -> OxcDiagnostic { /// TS(1273) #[cold] pub fn cannot_appear_on_a_type_parameter(modifier: &Modifier) -> OxcDiagnostic { - OxcDiagnostic::error(format!( - "'{}' modifier cannot be used on a type parameter.", - modifier.kind - )) - .with_label(modifier.span) + ts_error("1273", format!("'{}' modifier cannot be used on a type parameter.", modifier.kind)) + .with_label(modifier.span) } + /// TS(1090) pub fn cannot_appear_on_a_parameter(modifier: &Modifier) -> OxcDiagnostic { - OxcDiagnostic::error(format!( - "TS1090: '{}' modifier cannot appear on a parameter.", - modifier.kind - )) - .with_label(modifier.span) + ts_error("1090", format!("'{}' modifier cannot appear on a parameter.", modifier.kind)) + .with_label(modifier.span) } /// TS(18010) #[cold] pub fn accessibility_modifier_on_private_property(modifier: &Modifier) -> OxcDiagnostic { - OxcDiagnostic::error("An accessibility modifier cannot be used with a private identifier.") + ts_error("18010", "An accessibility modifier cannot be used with a private identifier.") .with_label(modifier.span) } diff --git a/tasks/coverage/parser_babel.snap b/tasks/coverage/parser_babel.snap index 1a79c2c878037..aa6945a802af7 100644 --- a/tasks/coverage/parser_babel.snap +++ b/tasks/coverage/parser_babel.snap @@ -1808,7 +1808,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ─── ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[core/uncategorised/454/input.js:1:1] 1 │ return · ────── @@ -9045,7 +9045,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ─ ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[esprima/invalid-syntax/migrated_0171/input.js:1:1] 1 │ return · ────── @@ -10062,7 +10062,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" 7 │ } ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[typescript/class/accessor-invalid/input.ts:3:3] 2 │ declare accessor prop7: number; 3 │ private accessor #p: any; @@ -10078,7 +10078,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── help: Try insert a semicolon here - × TS1030: 'declare' modifier already seen. + × TS(1030): declare' modifier already seen. ╭─[typescript/class/duplicate-modifier-1/input.ts:2:18] 1 │ class A { 2 │ declare public declare foo; @@ -10087,7 +10087,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── help: Remove the duplicate modifier. - × TS1030: 'declare' modifier already seen. + × TS(1030): declare' modifier already seen. ╭─[typescript/class/duplicate-modifier-2/input.ts:2:25] 1 │ class A { 2 │ declare public static declare foo; @@ -10096,7 +10096,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── help: Remove the duplicate modifier. - × TS1030: 'public' modifier already seen. + × TS(1030): public' modifier already seen. ╭─[typescript/class/duplicates-accessibility/input.ts:2:10] 1 │ class Foo { 2 │ public public a; @@ -10235,7 +10235,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" 11 │ } ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[typescript/class/private-fields-modifier-private/input.ts:2:3] 1 │ class A { 2 │ private #a; @@ -10243,7 +10243,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" 3 │ } ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[typescript/class/private-fields-modifier-protected/input.ts:2:3] 1 │ class A { 2 │ protected #a; @@ -10251,7 +10251,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" 3 │ } ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[typescript/class/private-fields-modifier-public/input.ts:2:3] 1 │ class A { 2 │ public #a; @@ -10306,7 +10306,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ─── ╰──── - × TS1030: 'declare' modifier already seen. + × TS(1030): declare' modifier already seen. ╭─[typescript/export/double-declare/input.ts:1:16] 1 │ export declare declare var name; · ─────── @@ -10427,7 +10427,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ─ ╰──── - × TS1095: A 'set' accessor cannot have a return type annotation + × TS(1095): A 'set' accessor cannot have a return type annotation. ╭─[typescript/interface/get-set-invalid-return-types/input.ts:2:17] 1 │ interface Foo { 2 │ set foo(param): string; @@ -10435,7 +10435,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" 3 │ } ╰──── - × TS1095: A 'set' accessor cannot have a return type annotation + × TS(1095): A 'set' accessor cannot have a return type annotation. ╭─[typescript/interface/get-set-invalid-return-types-babel-7/input.ts:2:17] 1 │ interface Foo { 2 │ set foo(param): string; @@ -10919,7 +10919,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ╰── `,` expected ╰──── - × 'public' modifier cannot be used on a type parameter. + × TS(1273): 'public' modifier cannot be used on a type parameter. ╭─[typescript/types/variance-annotations/input.ts:95:10] 94 │ 95 │ type T20 = T; // Error @@ -10927,7 +10927,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" 96 │ type T21 = T; // Error ╰──── - × TS1030: 'in' modifier already seen. + × TS(1030): in' modifier already seen. ╭─[typescript/types/variance-annotations/input.ts:96:17] 95 │ type T20 = T; // Error 96 │ type T21 = T; // Error @@ -10936,7 +10936,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── help: Remove the duplicate modifier. - × TS1030: 'out' modifier already seen. + × TS(1030): out' modifier already seen. ╭─[typescript/types/variance-annotations/input.ts:97:17] 96 │ type T21 = T; // Error 97 │ type T22 = T; // Error @@ -10945,7 +10945,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── help: Remove the duplicate modifier. - × 'public' modifier cannot be used on a type parameter. + × TS(1273): 'public' modifier cannot be used on a type parameter. ╭─[typescript/types/variance-annotations-babel-7/input.ts:95:10] 94 │ 95 │ type T20 = T; // Error @@ -10953,7 +10953,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" 96 │ type T21 = T; // Error ╰──── - × TS1030: 'in' modifier already seen. + × TS(1030): in' modifier already seen. ╭─[typescript/types/variance-annotations-babel-7/input.ts:96:17] 95 │ type T20 = T; // Error 96 │ type T21 = T; // Error @@ -10962,7 +10962,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── help: Remove the duplicate modifier. - × TS1030: 'out' modifier already seen. + × TS(1030): out' modifier already seen. ╭─[typescript/types/variance-annotations-babel-7/input.ts:97:17] 96 │ type T21 = T; // Error 97 │ type T22 = T; // Error @@ -10971,7 +10971,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── help: Remove the duplicate modifier. - × 'public' modifier cannot be used on a type parameter. + × TS(1273): 'public' modifier cannot be used on a type parameter. ╭─[typescript/types/variance-annotations-with-jsx/input.tsx:98:10] 97 │ 98 │ type T20 = T; // Error @@ -10979,7 +10979,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" 99 │ type T21 = T; // Error ╰──── - × TS1030: 'in' modifier already seen. + × TS(1030): in' modifier already seen. ╭─[typescript/types/variance-annotations-with-jsx/input.tsx:99:17] 98 │ type T20 = T; // Error 99 │ type T21 = T; // Error @@ -10988,7 +10988,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── help: Remove the duplicate modifier. - × TS1030: 'out' modifier already seen. + × TS(1030): out' modifier already seen. ╭─[typescript/types/variance-annotations-with-jsx/input.tsx:100:17] 99 │ type T21 = T; // Error 100 │ type T22 = T; // Error @@ -10997,7 +10997,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── help: Remove the duplicate modifier. - × 'public' modifier cannot be used on a type parameter. + × TS(1273): 'public' modifier cannot be used on a type parameter. ╭─[typescript/types/variance-annotations-with-jsx-babel-7/input.tsx:98:10] 97 │ 98 │ type T20 = T; // Error @@ -11005,7 +11005,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" 99 │ type T21 = T; // Error ╰──── - × TS1030: 'in' modifier already seen. + × TS(1030): in' modifier already seen. ╭─[typescript/types/variance-annotations-with-jsx-babel-7/input.tsx:99:17] 98 │ type T20 = T; // Error 99 │ type T21 = T; // Error @@ -11014,7 +11014,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── help: Remove the duplicate modifier. - × TS1030: 'out' modifier already seen. + × TS(1030): out' modifier already seen. ╭─[typescript/types/variance-annotations-with-jsx-babel-7/input.tsx:100:17] 99 │ type T21 = T; // Error 100 │ type T22 = T; // Error diff --git a/tasks/coverage/parser_test262.snap b/tasks/coverage/parser_test262.snap index 7f24f39228e43..08ebbf9d7b195 100644 --- a/tasks/coverage/parser_test262.snap +++ b/tasks/coverage/parser_test262.snap @@ -17038,7 +17038,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" ╰──── help: new.target is only allowed in constructors and functions invoked using thew `new` operator - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[language/global-code/return.js:22:1] 21 │ 22 │ return; @@ -20466,7 +20466,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" · ── ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[language/module-code/parse-err-return.js:32:1] 31 │ 32 │ return; @@ -28170,7 +28170,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 24 │ } ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[language/statements/class/static-init-invalid-return.js:24:7] 23 │ static { 24 │ return; @@ -32841,7 +32841,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" ╰──── help: Try insert a semicolon here - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[language/statements/return/S12.9_A1_T1.js:18:1] 17 │ var x=1; 18 │ return; @@ -32849,7 +32849,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 19 │ var y=2; ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[language/statements/return/S12.9_A1_T10.js:17:1] 16 │ //CHECK#1 17 │ return (0); @@ -32857,7 +32857,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 18 │ // ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[language/statements/return/S12.9_A1_T2.js:18:1] 17 │ var x=1; 18 │ return x; @@ -32865,7 +32865,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 19 │ var y=2; ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[language/statements/return/S12.9_A1_T3.js:18:5] 17 │ try { 18 │ return 1; @@ -32873,7 +32873,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 19 │ } catch(e){ ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[language/statements/return/S12.9_A1_T3.js:20:5] 19 │ } catch(e){ 20 │ return 1; @@ -32881,7 +32881,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 21 │ } ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[language/statements/return/S12.9_A1_T4.js:17:1] 16 │ //CHECK#1 17 │ return; @@ -32889,7 +32889,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 18 │ // ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[language/statements/return/S12.9_A1_T5.js:21:5] 20 │ var x=1; 21 │ return; @@ -32897,7 +32897,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 22 │ var y=2; ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[language/statements/return/S12.9_A1_T6.js:21:5] 20 │ var x=1; 21 │ return; @@ -32905,7 +32905,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 22 │ var y=2; ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[language/statements/return/S12.9_A1_T7.js:21:5] 20 │ var x=1; 21 │ return x; @@ -32913,7 +32913,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 22 │ var y=2; ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[language/statements/return/S12.9_A1_T8.js:21:5] 20 │ var x=1; 21 │ return x; @@ -32921,7 +32921,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 22 │ var y=2; ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[language/statements/return/S12.9_A1_T9.js:20:5] 19 │ } catch(e){ 20 │ return e; diff --git a/tasks/coverage/parser_typescript.snap b/tasks/coverage/parser_typescript.snap index 54097ca8b0063..2fbee292a82f1 100644 --- a/tasks/coverage/parser_typescript.snap +++ b/tasks/coverage/parser_typescript.snap @@ -5028,7 +5028,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" ╰──── help: Try insert a semicolon here - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[compiler/ambientWithStatements.ts:11:5] 10 │ L: var y; 11 │ return; @@ -5150,7 +5150,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 4 │ } ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[compiler/asiReturn.ts:2:1] 1 │ // This should be an error for using a return outside a function, but ASI should work properly 2 │ return @@ -6586,7 +6586,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" ╰──── help: Try insert a semicolon here - × TS1090: 'static' modifier cannot appear on a parameter. + × TS(1090): 'static' modifier cannot appear on a parameter. ╭─[compiler/constructorArgsErrors1.ts:2:18] 1 │ class foo { 2 │ constructor (static a: number) { @@ -6594,7 +6594,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 3 │ } ╰──── - × TS1090: 'static' modifier cannot appear on a parameter. + × TS(1090): 'static' modifier cannot appear on a parameter. ╭─[compiler/constructorArgsErrors2.ts:2:25] 1 │ class foo { 2 │ constructor (public static a: number) { @@ -6750,7 +6750,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 2 │ export default Foo ╰──── - × TS1030: 'declare' modifier already seen. + × TS(1030): declare' modifier already seen. ╭─[compiler/declareAlreadySeen.ts:2:13] 1 │ module M { 2 │ declare declare var x; @@ -6759,7 +6759,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" ╰──── help: Remove the duplicate modifier. - × TS1030: 'declare' modifier already seen. + × TS(1030): declare' modifier already seen. ╭─[compiler/declareAlreadySeen.ts:3:13] 2 │ declare declare var x; 3 │ declare declare function f(); @@ -6768,7 +6768,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" ╰──── help: Remove the duplicate modifier. - × TS1030: 'declare' modifier already seen. + × TS(1030): declare' modifier already seen. ╭─[compiler/declareAlreadySeen.ts:5:13] 4 │ 5 │ declare declare module N { } @@ -6777,7 +6777,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" ╰──── help: Remove the duplicate modifier. - × TS1030: 'declare' modifier already seen. + × TS(1030): declare' modifier already seen. ╭─[compiler/declareAlreadySeen.ts:7:13] 6 │ 7 │ declare declare class C { } @@ -7754,7 +7754,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 4 │ } ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[compiler/fileWithNextLine3.ts:3:1] 2 │ // 0. It should be counted as a space and should not trigger ASI 3 │ return…0; @@ -9042,7 +9042,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" · ──────── ╰──── - × TS1090: 'declare' modifier cannot appear on a parameter. + × TS(1090): 'declare' modifier cannot appear on a parameter. ╭─[compiler/modifierOnParameter1.ts:2:16] 1 │ class C { 2 │ constructor(declare p) { } @@ -9282,14 +9282,14 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 12 │ ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts:1:1] 1 │ return this.edit(role) · ────── 2 │ .then((role: Role) => ╰──── - × TS1030: 'public' modifier already seen. + × TS(1030): public' modifier already seen. ╭─[compiler/multipleClassPropertyModifiersErrors.ts:2:9] 1 │ class C { 2 │ public public p1; @@ -9298,7 +9298,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" ╰──── help: Remove the duplicate modifier. - × TS1030: 'private' modifier already seen. + × TS(1030): private' modifier already seen. ╭─[compiler/multipleClassPropertyModifiersErrors.ts:3:10] 2 │ public public p1; 3 │ private private p2; @@ -11419,7 +11419,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 26 │ // Errors on fifth-seventh ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[compiler/switchStatementsWithMultipleDefaults.ts:27:22] 26 │ // Errors on fifth-seventh 27 │ default: return; @@ -12797,7 +12797,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 5 │ return 1; ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[conformance/classes/classStaticBlock/classStaticBlock7.ts:5:9] 4 │ yield 1; 5 │ return 1; @@ -12813,7 +12813,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 25 │ ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[conformance/classes/classStaticBlock/classStaticBlock7.ts:36:13] 35 │ static { 36 │ return 1; @@ -12895,7 +12895,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 9 │ } ╰──── - × TS1030: 'readonly' modifier already seen. + × TS(1030): readonly' modifier already seen. ╭─[conformance/classes/constructorDeclarations/constructorParameters/readonlyReadonly.ts:2:14] 1 │ class C { 2 │ readonly readonly x: number; @@ -13713,7 +13713,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 25 │ a = b; // Error ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:2:5] 1 │ class A { 2 │ public #foo = 3; // Error @@ -13721,7 +13721,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 3 │ private #bar = 3; // Error ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:3:5] 2 │ public #foo = 3; // Error 3 │ private #bar = 3; // Error @@ -13729,7 +13729,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 4 │ protected #baz = 3; // Error ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:4:5] 3 │ private #bar = 3; // Error 4 │ protected #baz = 3; // Error @@ -13737,7 +13737,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 5 │ readonly #qux = 3; // OK ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:8:5] 7 │ 8 │ public #fooMethod() { return 3; } // Error @@ -13745,7 +13745,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 9 │ private #barMethod() { return 3; } // Error ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:9:5] 8 │ public #fooMethod() { return 3; } // Error 9 │ private #barMethod() { return 3; } // Error @@ -13753,7 +13753,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 10 │ protected #bazMethod() { return 3; } // Error ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:10:5] 9 │ private #barMethod() { return 3; } // Error 10 │ protected #bazMethod() { return 3; } // Error @@ -13761,7 +13761,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 11 │ readonly #quxMethod() { return 3; } // Error ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:17:5] 16 │ 17 │ public get #fooProp() { return 3; } // Error @@ -13769,7 +13769,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 18 │ public set #fooProp(value: number) { } // Error ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:18:5] 17 │ public get #fooProp() { return 3; } // Error 18 │ public set #fooProp(value: number) { } // Error @@ -13777,7 +13777,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 19 │ private get #barProp() { return 3; } // Error ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:19:5] 18 │ public set #fooProp(value: number) { } // Error 19 │ private get #barProp() { return 3; } // Error @@ -13785,7 +13785,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 20 │ private set #barProp(value: number) { } // Error ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:20:5] 19 │ private get #barProp() { return 3; } // Error 20 │ private set #barProp(value: number) { } // Error @@ -13793,7 +13793,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 21 │ protected get #bazProp() { return 3; } // Error ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:21:5] 20 │ private set #barProp(value: number) { } // Error 21 │ protected get #bazProp() { return 3; } // Error @@ -13801,7 +13801,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 22 │ protected set #bazProp(value: number) { } // Error ╰──── - × An accessibility modifier cannot be used with a private identifier. + × TS(18010): An accessibility modifier cannot be used with a private identifier. ╭─[conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:22:5] 21 │ protected get #bazProp() { return 3; } // Error 22 │ protected set #bazProp(value: number) { } // Error @@ -13857,7 +13857,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" ╰──── help: Try insert a semicolon here - × TS1030: 'public' modifier already seen. + × TS(1030): public' modifier already seen. ╭─[conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts:42:12] 41 │ private protected get getter() { return 0; } 42 │ public public set setter(a: number) { } @@ -13889,7 +13889,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 10 │ c ╰──── - × TS1030: 'accessor' modifier already seen. + × TS(1030): accessor' modifier already seen. ╭─[conformance/classes/propertyMemberDeclarations/autoAccessorDisallowedModifiers.ts:2:14] 1 │ abstract class C1 { 2 │ accessor accessor a: any; @@ -18290,7 +18290,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" · ─ ╰──── - × TS18007: JSX expressions may not use the comma operator. + × TS(18007): JSX expressions may not use the comma operator ╭─[conformance/jsx/jsxParsingError1.tsx:11:30] 10 │ const class2 = "bar"; 11 │ const elem =
; @@ -18454,7 +18454,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" ╰──── help: Try insert a semicolon here - × TS1030: 'override' modifier already seen. + × TS(1030): override' modifier already seen. ╭─[conformance/override/override5.ts:22:14] 21 │ 22 │ override override oop: number; @@ -18463,7 +18463,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" ╰──── help: Remove the duplicate modifier. - × TS1030: 'override' modifier already seen. + × TS(1030): override' modifier already seen. ╭─[conformance/override/override7.ts:19:14] 18 │ 19 │ override override oop: number; @@ -18603,7 +18603,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" ╰──── help: Try insert a semicolon here - × TS1030: 'public' modifier already seen. + × TS(1030): public' modifier already seen. ╭─[conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration6.ts:2:10] 1 │ class C { 2 │ public public constructor() { } @@ -18912,7 +18912,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" · ─ ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[conformance/parser/ecmascript5/ErrorRecovery/ModuleElements/parserErrorRecovery_ModuleElement1.ts:1:1] 1 │ return foo; · ────── @@ -19133,7 +19133,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" ╰──── help: Try insert a semicolon here - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[conformance/parser/ecmascript5/ErrorRecovery/parserStatementIsNotAMemberVariableDeclaration1.ts:1:1] 1 │ return { · ────── @@ -19510,7 +19510,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 3 │ } ╰──── - × TS1030: 'public' modifier already seen. + × TS(1030): public' modifier already seen. ╭─[conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration7.ts:2:12] 1 │ class C { 2 │ public public get Foo() { } @@ -19519,7 +19519,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" ╰──── help: Remove the duplicate modifier. - × TS1030: 'public' modifier already seen. + × TS(1030): public' modifier already seen. ╭─[conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration1.ts:2:12] 1 │ class C { 2 │ public public Foo() { } @@ -19593,7 +19593,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 13 │ } ╰──── - × TS1030: 'public' modifier already seen. + × TS(1030): public' modifier already seen. ╭─[conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration1.ts:2:10] 1 │ class C { 2 │ public public Foo; @@ -20211,13 +20211,13 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 4 │ while (true) { ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[conformance/parser/ecmascript5/Statements/ReturnStatements/parserReturnStatement1.ts:1:1] 1 │ return; · ────── ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[conformance/parser/ecmascript5/Statements/ReturnStatements/parserReturnStatement2.ts:2:4] 1 │ { 2 │ return; @@ -20323,13 +20323,13 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 2 │ } ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[conformance/parser/ecmascript5/Statements/parserReturnStatement1.d.ts:1:1] 1 │ return; · ────── ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[conformance/parser/ecmascript5/Statements/parserWithStatement2.ts:2:3] 1 │ with (1) 2 │ return; @@ -20530,7 +20530,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" · ── ╰──── - × TS1108: A 'return' statement can only be used within a function body + × TS(1108): A 'return' statement can only be used within a function body. ╭─[conformance/parser/ecmascript5/parserNotRegex1.ts:3:5] 2 │ { 3 │ return true; @@ -22906,7 +22906,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 2 │ let o8 = { ...*o }; ╰──── - × TS2681: A constructor cannot have a `this` parameter. + × TS(2681): A constructor cannot have a `this` parameter. ╭─[conformance/types/thisType/thisTypeInFunctionsNegative.ts:158:17] 157 │ class ThisConstructor { 158 │ constructor(this: ThisConstructor, private n: number) { @@ -22914,7 +22914,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 159 │ } ╰──── - × TS2681: A constructor cannot have a `this` parameter. + × TS(2681): A constructor cannot have a `this` parameter. ╭─[conformance/types/thisType/thisTypeInFunctionsNegative.ts:162:9] 161 │ interface ThisConstructorInterface { 162 │ new(this: ThisConstructor, n: number); @@ -22922,7 +22922,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 163 │ } ╰──── - × TS2681: A constructor cannot have a `this` parameter. + × TS(2681): A constructor cannot have a `this` parameter. ╭─[conformance/types/thisType/thisTypeInFunctionsNegative.ts:164:31] 163 │ } 164 │ var thisConstructorType: new (this: number) => number; @@ -22977,7 +22977,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 19 │ const a9 = (f); // Error, no applicable signatures ╰──── - × 'public' modifier cannot be used on a type parameter. + × TS(1273): 'public' modifier cannot be used on a type parameter. ╭─[conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts:95:10] 94 │ 95 │ type T20 = T; // Error @@ -22985,7 +22985,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" 96 │ type T21 = T; // Error ╰──── - × TS1030: 'in' modifier already seen. + × TS(1030): in' modifier already seen. ╭─[conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts:96:17] 95 │ type T20 = T; // Error 96 │ type T21 = T; // Error @@ -22994,7 +22994,7 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts" ╰──── help: Remove the duplicate modifier. - × TS1030: 'out' modifier already seen. + × TS(1030): out' modifier already seen. ╭─[conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts:97:17] 96 │ type T21 = T; // Error 97 │ type T22 = T; // Error