-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix circular constraint check #25913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When reviewing the baseline changes, note that the "disappearing" constraints are all in situations where a circularity error is also being reported. We now consistently remove constraints when they are circular. |
src/compiler/checker.ts
Outdated
const bc = (<Type>target).immediateBaseConstraint; | ||
return !!bc && bc !== circularConstraintType; | ||
} | ||
|
||
return Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're here revising this, it might be worth replacing Debug.fail(
with Debug.asserNever(propertyName
to guarantee exhaustiveness. Just a nit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but it might be worth commenting on getConstraintOfTypeParameter
and/or getConstraintFromTypeParameter
as to the nature of both and to which one you probably meant to use (similar to our comment on getContextualType
that reads "Woah! Do you really want to use this function?"
).
This PR ensures that we consistently call
getConstraintOfTypeParameter
to obtain type parameter constraints. ThegetConstraintOfTypeParameter
method protects against circular constraints, unlike the lower levelgetConstraintFromTypeParameter
helper function.Fixes #25740.