Skip to content

Clarify the error when an interface extends a constrained type parameter - #65506

Open
Lior-Altarescu wants to merge 1 commit into
microsoft:mainfrom
Lior-Altarescu:fix/interface-type-parameter-diagnostic
Open

Lior-Altarescu wants to merge 1 commit into
microsoft:mainfrom
Lior-Altarescu:fix/interface-type-parameter-diagnostic

Conversation

@Lior-Altarescu

Copy link
Copy Markdown

Fixes #57037.

interface Example<T extends object> extends T {} currently reports TS2430, which describes T as an interface. When the existing interface base-type assignability check fails for a type parameter, report TS2884 with a message that identifies the type parameter. The assignability check and its diagnostic details stay the same.

The regression test covers a constrained type parameter, an unconstrained type parameter, and an incompatible property inherited from another interface.

Verified with go test ./internal/testrunner from tsc/.

AI disclosure: Codex authored the patch. I reviewed the change and will handle maintainer feedback.

Copilot AI balanced review requested due to automatic review settings November 14, 2026 18:59
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 14, 2026
@typescript-automation typescript-automation Bot added For Backlog Bug PRs that fix a backlog bug labels Nov 14, 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.

🟢 Approval recommended

No active review issues block the targeted interface-inheritance diagnostic update.

No open issues 🎉

1 file not reviewed
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file
What changed in this PR

Addresses #57037 by making the native TypeScript compiler identify a constrained type parameter correctly when interface inheritance fails, without changing assignability checks or diagnostic details.

Changes:

  • Selects TS2884 instead of TS2430 when the failing base type is a type parameter.
  • Adds the diagnostic to the source catalog and generated registry and localization data.
  • Adds regression coverage for constrained and unconstrained type parameters and incompatible interface properties.
File Description
tsc/​testdata/​tests/​cases/​compiler/​interfaceExtendsConstrainedTypeParameter.ts Adds three interface-inheritance regression cases.
tsc/​testdata/​baselines/​reference/​compiler/​interfaceExtendsConstrainedTypeParameter.errors.txt Records TS2884 and preserves expected TS2312 and TS2430 diagnostics.
tsc/​internal/​diagnostics/​diagnostics_generated.go Defines and registers TS2884.
tsc/​internal/​diagnostics/​diagnosticMessages.json Adds the type-parameter-specific diagnostic message.
tsc/​internal/​diagnostics/​diagnosticMessages.generated.json Adds the generated localization key and English message.
tsc/​internal/​checker/​checker.go Selects the new diagnostic heading for type-parameter bases.

Review effort: Balanced

@Lior-Altarescu

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

Misleading error message when interface tries to extend constrained type parameter

2 participants