I'm interested in exploring specialization within Typescript generics, allowing for implementations to vary based on specific type criteria.
Here's a simple illustration:
const someFunction = <A>() => { return 0; }
// something similar to this
<A extends String>someFunction = (a: A) => { return 1; }
<A extends Number>someFunction = (a: A) => { return 2; }
.
.
.
console.log(someFunction(false)); // outputs 0
console.log(someFunction('string')); // outputs 1
console.log(someFunction(42)); // outputs 2
This presents the essence of what I'm aiming for. Can this be achieved in Typescript?