Allow negated types + F-bounded mapped types · Issue #18280 · microsoft/TypeScript (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@dead-claudia

Description

@dead-claudia

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:

Here's my proposal:

  1. Allow negated types, using !T to represent the set of all types that do not conform to T (i.e. not assignable to T). This is pretty simple to digest.
  2. 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.