Bug Report
When performing key remapping in mapped types, any property involving a generic type argument is dropped from the resulting type.
🔎 Search Terms
Mapped types with generic properties
Key remapping with generic properties
Properties with generic type dropped from mapped type with 'as' key remapping
🕗 Version & Regression Information
I first noticed it in 4.9.5 and still exhibited in nightly (5.1.*). Tried every version in playground down to 4.1.*, same behavior.
This is the behavior in every version I tried, and I reviewed the FAQ for entries about Type System Behavior, Classes, Generics.
⏯ Playground Link
Playground link with relevant code
💻 Code
exporttypeFilterNothing<T>={[PinkeyofTasT[P]extendsT[P] ? P : P]: T[P]}classTest<Z>{foo(args: FilterNothing<{key: number,value: Z,bar: Date}>){const{ key, value, bar }=args;// value is missing}}🙁 Actual behavior
value is omitted from the resulting type, even though all properties P are emitted. Any property that has a type involving a generic type parameter always gets dropped from the key remapping.
🙂 Expected behavior
value to be on the resulting type as Z, since its key would be emitted and type looked up by T[P].
Bug Report
When performing key remapping in mapped types, any property involving a generic type argument is dropped from the resulting type.
🔎 Search Terms
Mapped types with generic properties
Key remapping with generic properties
Properties with generic type dropped from mapped type with 'as' key remapping
🕗 Version & Regression Information
I first noticed it in
4.9.5and still exhibited innightly(5.1.*). Tried every version in playground down to4.1.*, same behavior.This is the behavior in every version I tried, and I reviewed the FAQ for entries about
Type System Behavior,Classes,Generics.⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
valueis omitted from the resulting type, even though all propertiesPare emitted. Any property that has a type involving a generic type parameter always gets dropped from the key remapping.🙂 Expected behavior
valueto be on the resulting type asZ, since its key would be emitted and type looked up byT[P].