Exploring the world of Advanced Type definitions in TypeScript has been quite the challenging journey for me, as I try to experiment with different approaches.
One concept I am keen on exploring is a "wizard-step-by-step" method:
function fillWizardOptions<T>() {
return <P extends T> (value: P) => {
return fillWizardOptions<Exclude<T, P>>();
}
}
The idea is that every time I call a chained sub-function, I aim to eliminate the previous option. However, my current use of Exclude
does not yield the expected results:
fillWizardOptions<string|number|boolean>()
('foo')
('bar');// Ideally, only number|boolean should remain here, but string|number|boolean persists
It seems like there could be something crucial that I'm overlooking.
If anyone knows where I can access a tool similar to a playground
but tailored for TypeScript, like what RegEx101 offers for regex testing,
Thank you.
Update: Just a heads up that I am working with TypeScript version 3.3.1