typelab / utils / ParseIntNegative
type ParseIntNegative<T> = ParseInt<T> extends infer Int ? Int extends 0 ? 0 : Int extends number ? IsNegative<Int> extends true ? Int : `-${Int}` extends `${infer Result extends number}` ? Result : never : never : never;Parses a string or number type into a negative number.
| Type Parameter | Description |
|---|---|
|
|
The type to parse. |
The parsed negative number type.
type Int = ParseIntNegative<'11'>; // -11