Skip to content

Require declare before abstract in class declarations - #65360

Merged
Ryan Cavanaugh (RyanCavanaugh) merged 3 commits into
mainfrom
copilot/fix-abstract-declare-class-issue
Nov 6, 2026
Merged

Ryan Cavanaugh (RyanCavanaugh) merged 3 commits into
mainfrom
copilot/fix-abstract-declare-class-issue

Conversation

Copilot AI commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #65356

Analysis

Modifier-order validation omitted declare after abstract, allowing both orders for ambient class declarations.

Fix

  • Validation: Report existing diagnostic TS1029 for reversed modifiers, preserving the reparsed-node exception.
  • Coverage: Exercise both orders in .ts and .d.ts files, including exported declarations.
declare abstract class A {} // Accepted
abstract declare class B {} // TS1029: 'declare' modifier must precede 'abstract' modifier.

Copilot Checklist

I successfully ran the applicable command at the end of my session, and it completed without error:

  • npx hereby validate
  • npx hereby validate --api (for TypeScript API changes)

Copilot AI and others added 2 commits November 6, 2026 16:30
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix compiler accepting abstract declare class syntax Require declare before abstract in class declarations Nov 6, 2026
@RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) marked this pull request as ready for review November 6, 2026 17:44
Copilot AI balanced review requested due to automatic review settings November 6, 2026 17:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change enforcing declare before abstract.

No open issues 🎉

What changed in this PR

Addresses #65356 by requiring declare to precede abstract in class declarations, using the compiler’s existing modifier-order diagnostic.

Changes:

  • Report TS1029 for reversed modifiers while preserving the reparsed-node exception.
  • Add regression coverage for both modifier orders in .ts and .d.ts files, including exported declarations.
  • Add diagnostic, type, and symbol baselines.
File Description
tsc/​testdata/​tests/​cases/​compiler/​declareAbstractModifierOrder.ts Tests accepted and rejected modifier orders.
tsc/​testdata/​baselines/​reference/​compiler/​declareAbstractModifierOrder.types Records class type information.
tsc/​testdata/​baselines/​reference/​compiler/​declareAbstractModifierOrder.symbols Records class symbol information.
tsc/​testdata/​baselines/​reference/​compiler/​declareAbstractModifierOrder.errors.txt Records four expected TS1029 diagnostics.
tsc/​internal/​checker/​grammarchecks.go Enforces declare before abstract.

Review effort: Balanced

@RyanCavanaugh

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test top999

@typescript-automation

typescript-automation Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top999 ✅ Started ✅ Results

@typescript-automation

Copy link
Copy Markdown
Contributor

Ryan Cavanaugh (@RyanCavanaugh) Here are the results of running the top 999 repos with tsc comparing baseline and pr:

Everything looks good!

@RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit c118174 Nov 6, 2026
35 checks passed
@RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) deleted the copilot/fix-abstract-declare-class-issue branch November 6, 2026 22:02
graphite-app Bot pushed a commit to oxc-project/oxc that referenced this pull request Nov 9, 2026
Reject `abstract declare` with TS1029 while preserving `declare abstract`, matching microsoft/TypeScript#65360. This applies to exported and unexported classes in `.ts` and `.d.ts` files, and to abstract properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiler accepts abstract declare class as well as declare abstract class

4 participants