-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Consider adding primitive
as a union of all primitive types
#39519
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
Comments
Given that |
|
aha, good point |
This is obviously coherent but the use case doesn't make sense to me. You support every primitive type except one, yet claim to be able to support any future primitive that appears? How can someone possibly know that the next primitive that gets added doesn't share the same characteristics of the one they don't support? |
For this specific use case that's true - I think Even with |
The strong arguments for this I would see are:
|
Search Terms
Suggestion
primitive
would be a union of all primitive types, e.g.:The advantage of doing this as a TypeScript built‑in rather than defining it in user space is that when a new primitive type gets added to ECMAScript (e.g.:
bigdecimal
), it will be supported automatically without needing to update the type definitions of the library.Use Cases
When describing an API that takes all‑but‑one primitive type, it’s useful to be able to do
Exclude<primitive, symbol>
orExclude<primitive, number | bigint>
without needing #29317.Examples
Checklist
My suggestion meets these guidelines:
Related
unknown
a union of theobject
and all primitive types #39498The text was updated successfully, but these errors were encountered: