typelab / utils / ParseBigIntPositive
type ParseBigIntPositive<T> = ParseBigInt<T> extends infer Bigi ? Bigi extends 0n ? 0n : Bigi extends bigint ? IsPositive<Bigi> extends true ? Bigi : `${Bigi}` extends `-${infer Result extends bigint}` ? Result : never : never : never;Parses a string or number type into a positive bigint.
| Type Parameter | Description |
|---|---|
|
|
The type to parse. |
The parsed positive bigint type.
type Bigi = ParseBigIntPositive<'-11'>; // 11n