fix(parser): report TS1242 for interfaces with abstract modifier (#27191)

## Summary

- Report TS1242 for `abstract interface` declarations using the existing illegal abstract modifier diagnostic.
- Refresh the Babel and TypeScript parser snapshots for their existing cases.
This commit is contained in:
camc314 committed 2026-09-29 16:42:58 +00:00
1 parent dd0bbb98a0
commit c6c6e5ee0d
3 files changed
+7 -7

No files matched your search

+4 -1
View File
@@ -243,7 +243,10 @@ impl<'a, C: Config> ParserImpl<'a, C> {
modifiers,
ModifierKinds::new([ModifierKind::Declare]),
true,
diagnostics::modifier_cannot_be_used_here,
|modifier, allowed| match modifier.kind {
ModifierKind::Abstract => diagnostics::illegal_abstract_modifier(modifier.span()),
_ => diagnostics::modifier_cannot_be_used_here(modifier, allowed),
},
);
if let Some((implements_kw_span, _)) = implements {
self.error(diagnostics::interface_implements(implements_kw_span));
+2 -4
View File
@@ -14312,13 +14312,12 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
· ──────────────────
╰────
× 'abstract' modifier cannot be used here.
× TS(1242): 'abstract' modifier can only appear on a class, method, or property declaration.
╭─[babel/packages/babel-parser/test/fixtures/typescript/interface/abstract/input.ts:1:1]
1 │ abstract interface Foo {
· ────────
2 │ foo: string;
╰────
help: Only 'declare' modifier is allowed here.
× Expected a semicolon or an implicit semicolon after a statement, but found none
╭─[babel/packages/babel-parser/test/fixtures/typescript/interface/declare-new-line/input.ts:1:8]
@@ -14328,13 +14327,12 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
╰────
help: Try inserting a semicolon here
× 'abstract' modifier cannot be used here.
× TS(1242): 'abstract' modifier can only appear on a class, method, or property declaration.
╭─[babel/packages/babel-parser/test/fixtures/typescript/interface/export-abstract-interface/input.ts:1:8]
1 │ export abstract interface I {
· ────────
2 │
╰────
help: Only 'declare' modifier is allowed here.
× Unexpected token
╭─[babel/packages/babel-parser/test/fixtures/typescript/interface/export-default/input.ts:1:26]
@@ -15958,12 +15958,11 @@ Expect to Parse: tasks/coverage/typescript/tsc/testdata/tests/cases/conformance/
3 │ }
╰────
× 'abstract' modifier cannot be used here.
× TS(1242): 'abstract' modifier can only appear on a class, method, or property declaration.
╭─[typescript/tsc/testdata/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts:1:1]
1 │ abstract interface I {}
· ────────
╰────
help: Only 'declare' modifier is allowed here.
× Identifier `C` has already been declared
╭─[typescript/tsc/testdata/tests/cases/conformance/classes/classDeclarations/classAndVariableWithSameName.ts:1:7]