-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Always resetErrorInfo if structuredTypeRelatedTo succeeds #49718
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
@typescript-bot test this |
Heya @jakebailey, I'm starting to run the diff-based user code test suite on this PR at b77d3e9. Hold tight - I'll update this comment with the log link once the build has been queued. |
Heya @jakebailey, I'm starting to run the extended test suite on this PR at b77d3e9. Hold tight - I'll update this comment with the log link once the build has been queued. |
I guess my question is whether there are other "missing" calls in this function, e.g. at https://github.com/microsoft/TypeScript/pull/49718/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8L19836 |
I totally agree, and so I made the change to wrap |
Heya @jakebailey, I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here. |
All of the differences were my mistake; I'll push the change here. But, I don't have any more tests for cases I'm missing. At least it'll feel like it won't be broken :D |
return result; | ||
} | ||
|
||
function structuredTypeRelatedToWorker(source: Type, target: Type, reportErrors: boolean, intersectionState: IntersectionState, saveErrorInfo: ReturnType<typeof captureErrorCalculationState>): Ternary { |
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.
saveErrorInfo
is kept because there are still some calls which explicitly reset it in order to hide certain errors that would be less helpful than others.
Fixes #49475
If
typeRelatedToDiscriminatedType
succeeds, then we have to clear the errors from previous steps as they are no longer true. Most of the previous steps do this too (but not all, confusingly).This manifested as being "uncomment this code, and the error goes away" because the call expression's call to
isRelatedTo
hadreportErrors=false
, while the class' call hadreportErrors=true
. The class check is deferred, so the call expression happened first, and the successful relationship was cached, then the error didn't appear later. Without the call expression, the error was reported even though it shouldn't have been.Rather than remembering to place those
resetErrorInfo
calls everywhere, turn the function into a worker and always reset if the relation succeeded.