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
interfaceFoo{a: string;b: number;c: boolean}// Omit has the issuetypeFooWithoutC=Omit<Foo,"c">;// no intellisense for second generic parametertypeFooWithoutD=Omit<Foo,"d">;// no type error// Counter example with PicktypeFooWithA=Pick<Foo,"a">;// provides intellisense for filling out second generic parametertypeFooWithD=Pick<Foo,"d">;// type error
Expected behavior:
In the above example, I would expect
to get auto-completion for keys of Foo when filling out the second generic parameter
to get a type error when putting in a key that does not exist on Foo
similar to how it works in all the other similar helpers, e.g. Pick.
Actual behavior:
Since the definition of the second generic parameter is keyof any instead of keyof T, I can put whatever I want into the second generic parameter, and I also get no Intellisense.
TypeScript Version: 3.6.0
Search Terms:
Omit
Omit any
Code
Expected behavior:
In the above example, I would expect
Foo
when filling out the second generic parameterFoo
similar to how it works in all the other similar helpers, e.g.
Pick
.Actual behavior:
Since the definition of the second generic parameter is
keyof any
instead ofkeyof T
, I can put whatever I want into the second generic parameter, and I also get no Intellisense.Related line:
TypeScript/src/lib/es5.d.ts
Line 1449 in ea73093
Playground Link: http://www.typescriptlang.org/play/#code/JYOwLgpgTgZghgYwgAgGIHt3IN4ChnJwBcyAzmFKAOYDc+yARiSAK4C2D0dBCJDmAGwhwQuAL65cAeinIA8m2BhkACzilkYFSmClSLCLjABPAA4oM6AOpKV6FmADCyALzzFYADyWANMgBECP4AfDTIMsggWKCQAgK6ECCkKDDoUGQQCOggACbIVInQwAjIpnBQcGwQkFBGZhaYNlr2YAAiru5K3ph+-jkhYRFRmvXI0FBpkhGO9uDQYwAelaZCyADutsgACsUA1nXmaI22AIIdOwi73ei9cAPhsqYTAG7AORAaMRBxCUkpacgYMAfiAqMgWhksrl8oVKCUyhUqjUDg1rLZ2m4LldfAF+qEHiNDuM0kA
Is there a reason why this has been implemented like this with
keyof any
instead ofkeyof T
?The text was updated successfully, but these errors were encountered: