-
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
Allow negated types + F-bounded mapped types #18280
Comments
Big 👍 on the proposed syntax. I think the negation operator is indeed quite intuitive in the context of mapped types/ Minor nitpick, but I believe your second item is already valid today. |
This comment should explain type negation outside a union context (partial Promise fix).
"not assignable to
Yeah...I figured this out; I just ran into this odd bug. |
keyof
to accept any type
I upvote |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
Edit:
keyof
works as I thought; mapped types are just broken in interfaces. I also clarified a few things.Allowing negated types and F-bounded mapped type variables would solve several issues:
A - B
could be encoded asA & !B
as per this proposal.Here's my proposal:
Allow negated types, using
!T
to represent the set of all types that do not conform toT
(i.e. not assignable toT
). This is pretty simple to digest.Expand mapped types to allow the key variable to be F-bounded, like in
{[P in Keys<T, P>]: ...}
.The first is sufficient to cover subtraction types and Promise type issues, and the other two make mapped conditional types possible.
The text was updated successfully, but these errors were encountered: