-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
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:
- Subtraction types: Subtraction types #4183 - The proposed
A - Bcould be encoded asA & !Bas per this proposal. - Mapped conditional types: Mapped conditional types #12424 - For key-based conditions, this + F-bounded mapped types would allow that to be solved without explicit support.
- Promises - Having negated types makes it possible to prevent thenables from being used as generic Promise parameters.
Here's my proposal:
-
Allow negated types, using
!Tto 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created