-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Use global NonNullable type for nonnull types #22096
Use global NonNullable type for nonnull types #22096
Conversation
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.
- How fast is this? Seems like it could be faster because of the caching, or slower because of the work in instantiating conditional types.
- This seems like a decent solution to NonNullable being missing, while still allowing user overrides. But our other built-ins that come from lib.d.ts don't behave this way yet. The worst are Array and Promise, which don't error but have bad behaviour. As part of the general push to switch the compiler to rely more on conditional types from lib.d.ts, we should revisit our handling of types like this.
|
No, although turning it on and obtaining a baseline from master would work, I think. That's what I did to test #22006. |
f61f6b7
to
67014b0
Compare
In my unscientific (ie, 10 iteration) tests, I'm not seeing any real difference just on the codebase using
|
Also changes NonNullableAssertions to no longer be constraint locations, as it is no longer required to work with the appropriate members/type relationships with this change.
This PR uses the global NonNullable type alias if it can be found, and failing finding it (ie, when an old lib is used), it will manufacture an anonymous conditional type of the appropriate shape to use in its place (which will behave the same way, it just won't be pretty in quick info or declaration emit).
Fixes #21317