-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Properly account for type parameters introduced by contextual types #59516
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 it |
Hey @ahejlsberg, the results of running the DT tests are ready. Everything looks the same! |
@ahejlsberg Here are the results of running the user tests with tsc comparing Everything looks good! |
@ahejlsberg Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@ahejlsberg Here are the results of running the top 400 repos with tsc comparing Something interesting changed - please have a look. Details
|
Performance is unaffected. One new error in |
Yeah, it's me who added this test of hono.js and I expected the failure. You can go forward |
if ((kind === SyntaxKind.FunctionExpression || kind === SyntaxKind.ArrowFunction || isObjectLiteralMethod(node)) && isContextSensitive(node as Expression | MethodDeclaration)) { | ||
const signature = firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfDeclaration(node as FunctionLikeDeclaration)), SignatureKind.Call)); | ||
if (signature && signature.typeParameters) { | ||
return [...(outerTypeParameters || emptyArray), ...signature.typeParameters]; |
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.
Should this be concatenate like the other cases? (Should also get rid of the empty array since I think it accepts undefined)
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.
We are required to return a mutable array, and concatenate
only returns a mutable array when both arguments are mutable arrays. In this case, signature.typeParameters
is read-only.
Can't get rid of the empty array, spreading undefined
causes an exception.
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 meant more that concatenate
can accept undefined
so you don't have to ||
things, but, yeah, it doesn't return a copy.
Though it's sort of confusing given all of the surrounding code uses append
/ concatenate
Fixes #59450.