Skip to content

Commit d30308f

Browse files
authored
fix: update UnexpectedPrivateField error message (#13975)
1 parent 6e22227 commit d30308f

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

packages/babel-parser/src/parser/error-message.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ export const ErrorMessages = makeErrorTemplates(
213213
"`new.target` can only be used in functions or class properties.",
214214
UnexpectedNumericSeparator:
215215
"A numeric separator is only allowed between two digits.",
216-
UnexpectedPrivateField:
217-
"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).",
216+
UnexpectedPrivateField: "Unexpected private name.",
218217
UnexpectedReservedWord: "Unexpected reserved word '%0'.",
219218
UnexpectedSuper: "'super' is only allowed in object methods and classes.",
220219
UnexpectedToken: "Unexpected token '%0'.",

packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-destructuring-arguments/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "File",
33
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
44
"errors": [
5-
"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)"
5+
"SyntaxError: Unexpected private name. (3:11)"
66
],
77
"program": {
88
"type": "Program",
@@ -107,4 +107,4 @@
107107
],
108108
"directives": []
109109
}
110-
}
110+
}

packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-destructuring/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "File",
33
"start":0,"end":59,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}},
44
"errors": [
5-
"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)"
5+
"SyntaxError: Unexpected private name. (4:12)"
66
],
77
"program": {
88
"type": "Program",
@@ -116,4 +116,4 @@
116116
],
117117
"directives": []
118118
}
119-
}
119+
}

packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-object-method/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "File",
33
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
44
"errors": [
5-
"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)"
5+
"SyntaxError: Unexpected private name. (2:11)"
66
],
77
"program": {
88
"type": "Program",
@@ -78,4 +78,4 @@
7878
],
7979
"directives": []
8080
}
81-
}
81+
}

packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-object-property/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "File",
33
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
44
"errors": [
5-
"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)"
5+
"SyntaxError: Unexpected private name. (2:11)"
66
],
77
"program": {
88
"type": "Program",
@@ -77,4 +77,4 @@
7777
],
7878
"directives": []
7979
}
80-
}
80+
}

packages/babel-parser/test/fixtures/es2022/class-private-properties/invalid-ts-type-literal/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "File",
33
"start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
44
"errors": [
5-
"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)"
5+
"SyntaxError: Unexpected private name. (2:3)"
66
],
77
"program": {
88
"type": "Program",
@@ -49,4 +49,4 @@
4949
],
5050
"directives": []
5151
}
52-
}
52+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy