diff --git a/packages/babel-parser/src/parser/error-message.js b/packages/babel-parser/src/parser/error-message.js index 4fb6c3ddfcce..b71b813f1072 100644 --- a/packages/babel-parser/src/parser/error-message.js +++ b/packages/babel-parser/src/parser/error-message.js @@ -213,8 +213,7 @@ export const ErrorMessages = makeErrorTemplates( "`new.target` can only be used in functions or class properties.", UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits.", - UnexpectedPrivateField: - "Private names can only be used as the name of a class element (i.e. class C { #p = 42; #m() {} } )\n or a property of member expression (i.e. this.#p).", + UnexpectedPrivateField: "Unexpected private name.", UnexpectedReservedWord: "Unexpected reserved word '%0'.", UnexpectedSuper: "'super' is only allowed in object methods and classes.", UnexpectedToken: "Unexpected token '%0'.", diff --git a/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-destructuring-arguments/output.json b/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-destructuring-arguments/output.json index 8a1f3e458127..e335d94d997e 100644 --- a/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-destructuring-arguments/output.json +++ b/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-destructuring-arguments/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}}, "errors": [ - "SyntaxError: Private names can only be used as the name of a class element (i.e. class C { #p = 42; #m() {} } )\n or a property of member expression (i.e. this.#p). (3:11)" + "SyntaxError: Unexpected private name. (3:11)" ], "program": { "type": "Program", @@ -107,4 +107,4 @@ ], "directives": [] } -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-destructuring/output.json b/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-destructuring/output.json index 0f46840ba8c7..ed66d5125c00 100644 --- a/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-destructuring/output.json +++ b/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-destructuring/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":59,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}}, "errors": [ - "SyntaxError: Private names can only be used as the name of a class element (i.e. class C { #p = 42; #m() {} } )\n or a property of member expression (i.e. this.#p). (4:12)" + "SyntaxError: Unexpected private name. (4:12)" ], "program": { "type": "Program", @@ -116,4 +116,4 @@ ], "directives": [] } -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-object-method/output.json b/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-object-method/output.json index 10e0158086e0..a7446d847fd7 100644 --- a/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-object-method/output.json +++ b/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-object-method/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Private names can only be used as the name of a class element (i.e. class C { #p = 42; #m() {} } )\n or a property of member expression (i.e. this.#p). (2:11)" + "SyntaxError: Unexpected private name. (2:11)" ], "program": { "type": "Program", @@ -78,4 +78,4 @@ ], "directives": [] } -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-object-property/output.json b/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-object-property/output.json index 7c27ba1380b6..f3622c7378cb 100644 --- a/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-object-property/output.json +++ b/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-object-property/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Private names can only be used as the name of a class element (i.e. class C { #p = 42; #m() {} } )\n or a property of member expression (i.e. this.#p). (2:11)" + "SyntaxError: Unexpected private name. (2:11)" ], "program": { "type": "Program", @@ -77,4 +77,4 @@ ], "directives": [] } -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-ts-type-literal/output.json b/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-ts-type-literal/output.json index abaf592123d0..c53dd5371ec0 100644 --- a/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-ts-type-literal/output.json +++ b/packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-ts-type-literal/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Private names can only be used as the name of a class element (i.e. class C { #p = 42; #m() {} } )\n or a property of member expression (i.e. this.#p). (2:3)" + "SyntaxError: Unexpected private name. (2:3)" ], "program": { "type": "Program", @@ -49,4 +49,4 @@ ], "directives": [] } -} \ No newline at end of file +}