Skip to content

Fix declaration emit crash on inaccessible heritage types - #64952

Open
Cheng (chengchuu) wants to merge 3 commits into
microsoft:mainfrom
chengchuu:fix/declaration-emit-heritage-crash
Open

Cheng (chengchuu) wants to merge 3 commits into
microsoft:mainfrom
chengchuu:fix/declaration-emit-heritage-crash

Conversation

@chengchuu

@chengchuu Cheng (chengchuu) commented Oct 24, 2026 •

Copy link
Copy Markdown

Summary

Fixes #64666

Report inaccessible heritage types instead of crashing during declaration emit. Recognize heritage type references as diagnostic contexts, preserve the enclosing context for class expressions, and use TS4082 for unnamed default-exported implementing classes to avoid malformed TS4019 messages.

Added regression coverage for interface extends, class implements, an inaccessible type argument, named and anonymous class expressions, and an unnamed default-exported class declaration.

Reproduction

The standalone reproduction prints panic: Diagnostic emitted without context and exits 2. The compiler should report diagnostics for the invalid input without crashing.

Validation

I manually ran the following checks from the repository root on macOS ARM64. All passed:

go -C ./tsc test \
  -run='TestLocal/(declarationEmitInaccessibleHeritageType|declarationEmitExpressionInExtends|declarationEmitForDefaultExportClassExtendingExpression|declarationEmitDefaultExport)' \
  ./internal/testrunner -count=1 -v
npx hereby test
npx hereby lint
npx hereby check:format

AI assistance: Copilot helped generate the regression tests. I reviewed the changes and will handle any review feedback or revisions myself.

Copilot AI balanced review requested due to automatic review settings October 24, 2026 15:54
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Oct 24, 2026
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Oct 24, 2026

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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.

🔵 Needs a closer look

Class-expression heritage bases are not fully handled and may still produce incorrect diagnostics.

No open issues 🎉

Review effort: Lite

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.

🟡 Changes recommended

The new context selects TS4019 for an unnamed default-exported class, producing a malformed diagnostic instead of using the existing default-export diagnostic.

1 open issue

Review effort: Max

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.

🔵 Needs a closer look

Human assessment is needed to weigh an unpublished, low-severity concern about duplicated node checks drifting apart and disrupting declaration diagnostics.

No open issues 🎉

1 resolved since last review

Review effort: Max

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

panic: Diagnostic emitted without context

2 participants