chore: enhance type to keep reference to its T - #259
Conversation
|
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
commit: |
ndisidore
left a comment
There was a problem hiding this comment.
Thanks for the DevEx wins and the included video! That's how you do a PR right there.
Looks good, just getting a few others on the team to take a look
Closes #258
When creating a stub type from a server class
T, it drop keys such as brand symbols. Currently it iterates withExclude<keyof T, …>, which makes TypeScript then treats the result as a new object, so "Go to Definition" onapi.authenticate()no longer jumps toT.authenticate. This PR still drops the same keys, but maps overkeyof Tfirst and thenPick.Here is a minimal PoC difference between using
Exclude<keyof T, …>vs usingPick:https://www.typescriptlang.org/play/?#code/MYGwhgzhAEDKYFsAOICm0DeAoa0BmA9gQBQCUmOu0ATqgC4Cu1AdtHdQ6gNyUC+lAIzDUyFKjXpNW7Tj1z9+WOgE8k6AIIAeACoA+aAF4x0ANoBpaAEtWAUQAeoBgBNUmgNaplBPNG0AaaAByIWpA3QBdAC5fc3CeXh4lVXQAIR19IwAFS2A3TUpscXMrVg8vH20omLM4vj9Ke0cXd09vXwDg4TCsXUSXUGF0YAJmCDpoMGiteGQ0Xqx+8FpoYdHxgWi0mZRUeawwADpCElIeAHoz6AA9AH4sASOiMnPL26wsIA
capnweb.mp4