Would it be useful to be able to convert a number in a string to a number literal type? '100' => 100.
I guess a more strictly typed Number.parseInt could take advantage of this.
type SomeNum = "100" extends `${infer U extends number}` ? U : never;
// 100
We cannot do ParseNumber because if it doesn't match exactly, it just returns a number type instead of 100:
type SomeNum = "100.0" extends `${infer U extends number}` ? U : never;
// number
We could also maybe do ParseBoolean and maybe Is methods too (IsInteger)?
Maybe it's not that useful. Feedback wanted.
Would it be useful to be able to convert a number in a string to a number literal type?
'100'=>100.I guess a more strictly typed
Number.parseIntcould take advantage of this.We cannot do
ParseNumberbecause if it doesn't match exactly, it just returns anumbertype instead of100:We could also maybe do
ParseBooleanand maybeIsmethods too (IsInteger)?Maybe it's not that useful. Feedback wanted.