You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using generic argument that extends something, stops inferring super keys when Exclude is used in addition to keyof and Pick #27928
interfaceBase{base1: number;base2: number;}classData<TextendsBase>{alpha(k:keyofPick<T,Exclude<keyofT,"base1">>){}beta(k:keyofPick<T,keyofT>){}}functionwrapped<TextendsBase>(){letd=newData<T>();d.alpha("base2");// Argument of type '"base2"' is not assignable to parameter of type 'Exclude<keyof T, "base1">'. d.beta("base2");// works}
Expected behavior:
Both alpha and beta should work.
Actual behavior:
Alpha does not work: ` Argument of type '"base2"' is not assignable to parameter of type 'Exclude<keyof T, "base1">'.
I'm not sure, but I think I've found the same issue in v3.3.1. Please let me know if I'm wrong and I can open a new issue. This is a minimal reproduction, my real use case has the Exclude<Exclude type generated from nested react higher order components.
interfaceBase{a: number;b: number;c: number;d: number;e: number;f: number;}typeBaseA=Exclude<keyofBase,"a"|"c"|"b"|"d">;typeBaseB=Exclude<Exclude<keyofBase,"a"|"b">,"c"|"d">;functiontestingBase(a: BaseA): BaseB{returna;// works, as expected}typeA<T>=Exclude<keyofT,"a"|"c"|"b"|"d">;typeB<T>=Exclude<Exclude<keyofT,"a"|"b">,"c"|"d">;functiontesting<T>(a: A<T>): B<T>{returna;// fails unexpectedly with "Type 'Exclude<keyof T, "a" | "b" | "c" | "d">' is not assignable to type 'Exclude<Exclude<keyof T, "a" | "b">, "c" | "d">'."}
Activity
DanielRosenwasser commentedon Oct 25, 2018
Any thoughts on this one Wesley Wigham (@weswigham) Anders Hejlsberg (@ahejlsberg)?
apexskier commentedon Feb 7, 2019
I'm not sure, but I think I've found the same issue in v3.3.1. Please let me know if I'm wrong and I can open a new issue. This is a minimal reproduction, my real use case has the
Exclude<Excludetype generated from nested react higher order components.playground