Q:

Reducing TypeScript Type possibility with recursive typing

Since TypeScript allows Advanced Type definition, I want to experiment a lot this approach, but it's not as easy as I expected.
For example, I want to have a kind of "wizard-step-by-step" method:
function fillWizardOptions<T>() {
     return <P extends T> (value:  P) => {
         return fillWizardOptions<Exclude<T, P>>();
     }
}

So each time I call a chained sub-function, I want to lose the previous option, but currently, Exclude doesn't work as I was expected:
fillWizardOptions<string|number|boolean>()
     ('foo')
     ('bar');// Expect here of have only number|boolean, but I still have string|number|boolean

Probably I miss something.
Also, if someone know where I can find a kind of playground like for RegEx101
Thanks.
Update: forget to mention that I'm using TypeScript 3.3.1

A:

In this case, for the first call, the <P> instead of implementing string type, it has the 'foo' type. So that's why it didn't exclude string from T. Therefore, it should work if you write ('foo' as string) or (<string>'foo')

