vtils

Home > types > NonNegative

NonNegative type

A non-negative number/bigint (0 <= x < ∞).

Use-case: Validating and documenting parameters.

Signature:

export declare type NonNegative<T extends Numeric> = T extends Zero ? T : Negative<T> extends never ? T : never;

References: Negative

Example

``` import {NonNegative} from ‘type-fest’;

declare function setLength<T extends number>(length: NonNegative): void; \`\`\`

Utilities