How do I use the return type of a function with overloads that will be returned in the same function
I'm creating a library, but I have a problem when I use a function with overloads to return itself in some instances. It won't be able to determine the right type.
Solution:Jump to solution
DominicVonk
CodeSandbox
fast-rain-pyixhv - CodeSandbox
fast-rain-pyixhv by DominicVonk using parcel-bundler
4 Replies
This one works without the "magic": https://codesandbox.io/s/distracted-payne-1fe5fm?file=/src/index.ts
DominicVonk
CodeSandbox
distracted-payne-1fe5fm - CodeSandbox
distracted-payne-1fe5fm by DominicVonk using parcel-bundler
This is the with the isse:
DominicVonk
CodeSandbox
wizardly-bhabha-md6kzw - CodeSandbox
wizardly-bhabha-md6kzw by DominicVonk using parcel-bundler
Solution
I found a workaround using classes:
https://codesandbox.io/s/fast-rain-pyixhv?file=/src/index.ts
DominicVonk
CodeSandbox
fast-rain-pyixhv - CodeSandbox
fast-rain-pyixhv by DominicVonk using parcel-bundler