import type {StringToNumber} from 'type-fest';
type PositiveInteger = StringToNumber<'1234'>;
//=> 1234
type NegativeInteger = StringToNumber<'-1234'>;
//=> -1234
type PositiveFloat = StringToNumber<'1234.56'>;
//=> 1234.56
type NegativeFloat = StringToNumber<'-1234.56'>;
//=> -1234.56
type PositiveInfinity = StringToNumber<'Infinity'>;
//=> Infinity
type NegativeInfinity = StringToNumber<'-Infinity'>;
//=> -Infinity
Note: Some strings, such as '1.50', '0b10', or '12_345', may look like they can be converted to numbers, but they don't actually have corresponding numeric literals. So, in such cases, this type produces never. See type-fest#1446 for more details.
Converts a numeric string to a number.