Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 684 Bytes

File metadata and controls

42 lines (30 loc) · 684 Bytes

typelab / utils / ParseBigIntNegative

type ParseBigIntNegative<T> = ParseBigInt<T> extends infer Bigi ? Bigi extends 0n ? 0n : Bigi extends bigint ? IsNegative<Bigi> extends true ? Bigi : `-${Bigi}` extends `${infer Result extends bigint}` ? Result : never : never : never;

Parses a string or number type into a negative bigint.

Type Parameters

Type Parameter Description

T

The type to parse.

Returns

The parsed negative bigint type.

Example

type Bigi = ParseBigIntNegative<'11'>; // -11n