mirror of
https://github.com/aphrody-labs/oxc.git
synced 2026-10-14 22:29:17 +00:00
fix(parser): report abstract private field error on modifier (#27314)
For `abstract #quux = 3`, report TS18019 on the `abstract` keyword instead of the private identifier, matching TypeScript. Keep the boolean check on the fast path and retrieve the modifier span only when reporting the error.
This commit is contained in:
1 parent
2ff6fb51da
commit
6a7d48b4a7
3 files changed
+8
-7
No files matched your search
@@ -797,7 +797,8 @@ impl<'a, C: Config> ParserImpl<'a, C> {
|
||||
}
|
||||
}
|
||||
if r#abstract && name.is_private_identifier() {
|
||||
self.error(diagnostics::abstract_with_private_identifier(name.span()));
|
||||
let modifier = modifiers.get(ModifierKind::Abstract).unwrap();
|
||||
self.error(diagnostics::abstract_with_private_identifier(modifier.span()));
|
||||
}
|
||||
if r#abstract && initializer.is_some() {
|
||||
let (name, span) = self.abstract_member_name(&name);
|
||||
|
||||
@@ -12459,10 +12459,10 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
|
||||
help: Try inserting a semicolon here
|
||||
|
||||
× TS(18019): 'abstract' modifier cannot be used with a private identifier.
|
||||
╭─[babel/packages/babel-parser/test/fixtures/estree/class-private-property/typescript-invalid-abstract/input.ts:2:12]
|
||||
╭─[babel/packages/babel-parser/test/fixtures/estree/class-private-property/typescript-invalid-abstract/input.ts:2:3]
|
||||
1 │ abstract class TSAbstractClass {
|
||||
2 │ abstract #foo: boolean;
|
||||
· ────
|
||||
· ────────
|
||||
3 │ }
|
||||
╰────
|
||||
|
||||
@@ -13722,10 +13722,10 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
|
||||
╰────
|
||||
|
||||
× TS(18019): 'abstract' modifier cannot be used with a private identifier.
|
||||
╭─[babel/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-abstract/input.ts:2:12]
|
||||
╭─[babel/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-abstract/input.ts:2:3]
|
||||
1 │ abstract class A {
|
||||
2 │ abstract #a;
|
||||
· ──
|
||||
· ────────
|
||||
3 │ }
|
||||
╰────
|
||||
|
||||
|
||||
@@ -18261,10 +18261,10 @@ Expect to Parse: tasks/coverage/typescript/tsc/testdata/tests/cases/conformance/
|
||||
╰────
|
||||
|
||||
× TS(18019): 'abstract' modifier cannot be used with a private identifier.
|
||||
╭─[typescript/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:32:14]
|
||||
╭─[typescript/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:32:5]
|
||||
31 │ abstract class B {
|
||||
32 │ abstract #quux = 3; // Error
|
||||
· ─────
|
||||
· ────────
|
||||
33 │ }
|
||||
╰────
|
||||
|
||||
|
||||
Reference in new issue
Block a user