mirror of
https://github.com/aphrody-labs/oxc.git
synced 2026-10-15 06:39:17 +00:00
fix(parser): report TS1243 for abstract async methods (#27192)
Report TS1243 when `abstract` and `async` are combined on a method in either order. The existing TypeScript conformance case covers both forms. Babel accepts `abstract async`, so the updated Babel snapshots record the resulting parser and semantic coverage difference.
This commit is contained in:
1 parent
c6c6e5ee0d
commit
5914a24cfa
4 files changed
+46
-3
No files matched your search
@@ -698,12 +698,14 @@ const fn get_illegal_preceding_modifiers(kind: ModifierKind) -> ModifierKinds {
|
||||
ModifierKind::Async,
|
||||
ModifierKind::Declare,
|
||||
]),
|
||||
ModifierKind::Async => ModifierKinds::new([ModifierKind::Async, ModifierKind::Abstract]),
|
||||
ModifierKind::Abstract => ModifierKinds::new([
|
||||
ModifierKind::Abstract,
|
||||
ModifierKind::Override,
|
||||
ModifierKind::Accessor,
|
||||
ModifierKind::Static,
|
||||
ModifierKind::Private,
|
||||
ModifierKind::Async,
|
||||
]),
|
||||
ModifierKind::Export => ModifierKinds::new([
|
||||
ModifierKind::Export,
|
||||
@@ -746,7 +748,7 @@ impl<'a, C: Config> ParserImpl<'a, C> {
|
||||
ModifierKind::Private,
|
||||
ModifierKind::Protected,
|
||||
]);
|
||||
use ModifierKind::{Abstract, Declare, Override, Private, Static};
|
||||
use ModifierKind::{Abstract, Async, Declare, Override, Private, Static};
|
||||
|
||||
let this_kind = modifier.kind;
|
||||
let this_kinds = ModifierKinds::new([this_kind]);
|
||||
@@ -785,6 +787,9 @@ impl<'a, C: Config> ParserImpl<'a, C> {
|
||||
(Private, Abstract) | (Abstract, Private) => {
|
||||
diagnostics::modifier_cannot_be_used_with_other_modifier(span, Private, Abstract)
|
||||
}
|
||||
(Async, Abstract) | (Abstract, Async) => {
|
||||
diagnostics::modifier_cannot_be_used_with_other_modifier(span, Async, Abstract)
|
||||
}
|
||||
// `declare override`
|
||||
(Override, Declare) => {
|
||||
diagnostics::modifier_cannot_be_used_with_other_modifier(span, Override, Declare)
|
||||
|
||||
@@ -2,7 +2,7 @@ commit: fd665901
|
||||
|
||||
parser_babel Summary:
|
||||
AST Parsed : 2239/2239 (100.00%)
|
||||
Positive Passed: 2223/2239 (99.29%)
|
||||
Positive Passed: 2222/2239 (99.24%)
|
||||
Negative Passed: 1732/1746 (99.20%)
|
||||
Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/cast/unparenthesized-assert-and-assign/input.ts
|
||||
|
||||
@@ -134,6 +134,24 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
|
||||
5 │ }
|
||||
╰────
|
||||
|
||||
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/class/modifiers-methods-async/input.ts
|
||||
|
||||
× TS(1243): 'async' modifier cannot be used with 'abstract' modifier.
|
||||
╭─[babel/packages/babel-parser/test/fixtures/typescript/class/modifiers-methods-async/input.ts:3:14]
|
||||
2 │ abstract class C {
|
||||
3 │ abstract async a();
|
||||
· ─────
|
||||
4 │ static async s() {}
|
||||
╰────
|
||||
|
||||
× TS(1243): 'async' modifier cannot be used with 'abstract' modifier.
|
||||
╭─[babel/packages/babel-parser/test/fixtures/typescript/class/modifiers-methods-async/input.ts:5:21]
|
||||
4 │ static async s() {}
|
||||
5 │ public abstract async pua();
|
||||
· ─────
|
||||
6 │ public static async pus() {}
|
||||
╰────
|
||||
|
||||
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/class/modifiers-override/input.ts
|
||||
|
||||
× Identifier `show` has already been declared
|
||||
|
||||
@@ -15926,6 +15926,22 @@ Expect to Parse: tasks/coverage/typescript/tsc/testdata/tests/cases/conformance/
|
||||
14 │
|
||||
╰────
|
||||
|
||||
× TS(1243): 'async' modifier cannot be used with 'abstract' modifier.
|
||||
╭─[typescript/tsc/testdata/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts:15:14]
|
||||
14 │
|
||||
15 │ abstract async foo_f();
|
||||
· ─────
|
||||
16 │ async abstract foo_g();
|
||||
╰────
|
||||
|
||||
× TS(1243): 'async' modifier cannot be used with 'abstract' modifier.
|
||||
╭─[typescript/tsc/testdata/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts:16:11]
|
||||
15 │ abstract async foo_f();
|
||||
16 │ async abstract foo_g();
|
||||
· ────────
|
||||
17 │ }
|
||||
╰────
|
||||
|
||||
× TS(2391): Function implementation is missing or not immediately following the declaration.
|
||||
╭─[typescript/tsc/testdata/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts:15:5]
|
||||
14 │
|
||||
|
||||
@@ -2,7 +2,7 @@ commit: fd665901
|
||||
|
||||
semantic_babel Summary:
|
||||
AST Parsed : 2239/2239 (100.00%)
|
||||
Positive Passed: 2149/2239 (95.98%)
|
||||
Positive Passed: 2148/2239 (95.94%)
|
||||
semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/comments/decorators/decorators-after-export/input.js
|
||||
Symbol flags mismatch for "_default":
|
||||
after transform: SymbolId(3): SymbolFlags(Class)
|
||||
@@ -121,6 +121,10 @@ semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescr
|
||||
Function implementation is missing or not immediately following the declaration.
|
||||
Function implementation is missing or not immediately following the declaration.
|
||||
|
||||
semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/class/modifiers-methods-async/input.ts
|
||||
'async' modifier cannot be used with 'abstract' modifier.
|
||||
'async' modifier cannot be used with 'abstract' modifier.
|
||||
|
||||
semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/class/modifiers-override/input.ts
|
||||
Identifier `show` has already been declared
|
||||
Identifier `size` has already been declared
|
||||
|
||||
Reference in new issue
Block a user