-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Revert #54477 but keep the tests #57160
Revert #54477 but keep the tests #57160
Conversation
Discovered in microsoft#57117 The implementation should not `couldContainTypeVariables`--it's not intended a fast path, and should not be used in places where its unreliability can be observed. The tests stay, but with a note added that they should pass but do not.
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.
This is a minimal repro for the break, right?
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.
yes
const signature = getSingleCallSignature(funcType); | ||
if (signature) { | ||
const returnType = getReturnTypeOfSignature(signature); | ||
if (!signature.typeParameters || !couldContainTypeVariables(returnType)) { |
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.
I try to understand how to use couldContainTypeVariables
appropriately and I wonder how this was different from how checkFunctionExpressionOrObjectLiteralMethod
uses it here?
// The identityMapper object is used to indicate that function expressions are wildcards
if (checkMode && checkMode & CheckMode.SkipContextSensitive && isContextSensitive(node)) {
// Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage
if (!getEffectiveReturnTypeNode(node) && !hasContextSensitiveParameters(node)) {
// Return plain anyFunctionType if there is no possibility we'll make inferences from the return type
const contextualSignature = getContextualSignature(node);
if (contextualSignature && couldContainTypeVariables(getReturnTypeOfSignature(contextualSignature))) {
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.
I see how this is part of the inference algorithm and the check here was kinda not - but I still fail to understand how those 2 situations are fundamentally different so it's OK to call it within one context and not OK to call it within another.
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.
I'm not sure that other use is correct either...
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.
I also tried to repro the regression caused by this cause I wanted to add a test case for it but I failed. It has been mentioned that it was only visible in the IDE but I assume that this particular report was reported by a bot reporting tsc
-related changes. I couldn't repro with either though.
Discovered in #57117 for the 5.4 beta.
The implementation should not use
couldContainTypeVariables
--it's intended as a fast path, and should not be used in places where its unreliability can be observed.The tests stay, but with a note added that they should pass but do not.