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
typeExcept<T,KextendskeyofT>=Pick<T,{[PinkeyofT]: PextendsK ? never : P}[keyofT]>;interfaceI1{foo: string;}functionF1<TextendsI1>(): Except<T,''>{// error is shown but autocomplete is not provided//codereturnnull;}
Expected behavior:
Having autocomplete showing when extending a generic
Actual behavior:
Even if error is correctly displayed, no autocomplete is shown for a T extends with a known type on the right hand.
I got very confused when extending the generic. Check this out for some sort of explanation why this probably isn't implemented: https://stackoverflow.com/a/58417200/7731090. I do one up your suggestion nonetheless.
I can understand why it wouldn't type, because the generic is generic . The other side of the coin is that it should at least provide values on the values it DOES know. I think it would stop some confusion and nice to have, but what drawbacks are there to consider?
Activity
waynevanson commentedon Oct 16, 2019
I got very confused when extending the generic. Check this out for some sort of explanation why this probably isn't implemented: https://stackoverflow.com/a/58417200/7731090. I do one up your suggestion nonetheless.
I can understand why it wouldn't type, because the generic is generic . The other side of the coin is that it should at least provide values on the values it DOES know. I think it would stop some confusion and nice to have, but what drawbacks are there to consider?
lsagetlethias commentedon Oct 18, 2019
I don't think about any major drawbacks; I think there will even be some good side-effects.
Going from this:

To this:

will also limit noises in Intellisense results.
chrg1001 commentedon May 16, 2022
I found another example (more simple).
playground
eythaann commentedon Oct 17, 2022
ciriousjoker commentedon Mar 17, 2023
Here's another example that seems to be caused by the same root issue:
Typescript Playground
mkantor commentedon May 8, 2023
FWIW
keyofis not necessary in the generic function case. This example also does not provide type-aware autocomplete suggestions:Miguel-A-Jara commentedon May 6, 2025
Any news on this issue? Still occurring as of TypeScript
5.3.3mkantor commentedon Aug 1, 2025
The scenarios described above in @chrg1001's comment and in my comment would be addressed by #62170.