Repository navigation
Clarify the error when an interface extends a constrained type parameter - #65506
Open
Lior-Altarescu wants to merge 1 commit into
Open
Lior-Altarescu wants to merge 1 commit into
Lior-Altarescu wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 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
Author
|
@microsoft-github-policy-service agree |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #57037.
interface Example<T extends object> extends T {}currently reports TS2430, which describesTas 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/testrunnerfromtsc/.AI disclosure: Codex authored the patch. I reviewed the change and will handle maintainer feedback.