-
Notifications
You must be signed in to change notification settings - Fork 12.9k
fix: crashes when JSX.IntrinsicClassAttributes is an alias type close GH-50254 #50257
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
Thanks! |
if (typeParams && typeParams.length === 1) { | ||
const inferredArgs = fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), isInJSFile(context)); |
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.
oh, since I checked the typeParams length, I should not call fillMissingTypeArguments
.
Which is preferred? To limit the generics number of JSX.IntrinsicClassAttributes = 1, or allow any argument count and call fillMissingTypeArguments
to fill it?
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 usually err on the side of being permissive, since we've never surfaced real errors for these intrinsic types - so allowing too many arguments, but only providing the first and defaulting/constraint'ing the rest. Not much reasoning for either way, though. It's essentially a quiet error case.
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.
Actually, they're not intrinsic types, they're installed from npm. That's also true for libes6.d.ts etc, you can use nolib
and provide you're own Promise<T>
type. Maybe there's more incorrect cast in the checker assuming the shape of the library types and might crash under some edge cases.
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.
Most use the getGlobalType
function which issues an error if arity doesn't match what we expect. The JSX types have just always been a bit more lax.
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 opened #50271 to clean up the code.
Fixes #50254