In my current example, I am showcasing conditional arguments where the value of the second argument depends on the type of the first one.
type Check<F, S> = S extends number ? string : number
function Example<S>(arg: S) {
return function <P>(arg: Check<P, S>) {
}
}
// Valid:
Example('hello')(1)
Example(1)('hello')
How can I modify the above code to achieve this desired functionality?
Example()(1)
Example(1)()
The challenge is that adding a ?
makes the argument permanently optional, while leaving it out makes it required.