Is it possible to write a utility type Number<T> which accepts a string literal type that can be converted to a number, if not it returns a never type?
type Five = Number<'5'> // `Five` is of the type number 5
And I just wanted to preemptively answer the question about why I want to do this:
The reason I am asking this question is that I am trying to write an Add utility type which adds the number
type createArray<Len, Ele, Arr extends Ele[] = []> = Arr['length'] extends Len ? Arr : createArray<Len, Ele, [Ele, ...Arr]>
type Add<A extends number, B extends number> = [...createArray<A, 1>, ...createArray<B, 1>]['length']
Right now it works
type Answer = Add<3,10> // Answer is 13
But but it only accepts the number type. I wanted to make it also doesn't accept string type so that this also works type Answer = Add<'3','10'>