import { type BoolAnd, type BoolNot, type Brand, type IsNever } from 'ts-type-forge'; import { type Type } from '../type.mjs'; type NumberType = number; export declare function number(defaultValue?: NumberType): Type; export declare function number(defaultValue: N & DefaultValueType, constraints: C): Type>; type Constraints = Partial>; /** * The set of constraints accepted by {@link number}. */ export type NumberTypeConstraints = Constraints; /** * The numeric-range subset of {@link NumberTypeConstraints}. These constraints * (`gt`, `gte`, `min`, `lt`, `lte`, `max`, `multipleOf`, `step`) add runtime * validation without changing the result brand, so the branded number types * under `predefined/brand/number` accept only this subset. To build a different * brand from a plain number, use {@link number} with the predicate constraints * instead, or the dedicated branded constructor for the target type. */ export type NumberRangeConstraints = Pick; type DefaultValueType = DefaultValueWhenNonZeroIsOn & DefaultValueWhenNegativeIsOn & DefaultValueWhenNonNegativeIsOn & DefaultValueWhenPositiveIsOn & DefaultValueWhenNonPositiveIsOn; type ConstraintsToResultType = ConstraintsToResultHelperType>; type ConstraintsToResultHelperType> = IsNever extends true ? NumberType : Brand; type ConstraintsToResultBrandKeys = (C extends Readonly<{ int: true; }> ? Readonly<{ brandKeys: 'Int' | 'Finite'; brandFalseKeys: 'NaNValue'; }> : never) | (C extends Readonly<{ safeInteger: true; }> ? Readonly<{ brandKeys: 'Finite' | 'Int' | 'SafeInt'; brandFalseKeys: 'NaNValue'; }> : never) | (C extends Readonly<{ finite: true; }> ? Readonly<{ brandKeys: 'Finite'; brandFalseKeys: 'NaNValue'; }> : never) | (C extends Readonly<{ nonZero: true; }> ? Readonly<{ brandKeys: '!=0'; brandFalseKeys: 'NaNValue'; }> : never) | (C extends Readonly<{ negative: true; }> ? Readonly<{ brandKeys: '!=0' | '< 2^15' | '< 2^16' | '< 2^31' | '< 2^32' | '<=0'; brandFalseKeys: '>=0' | 'NaNValue'; }> : never) | (C extends Readonly<{ nonNegative: true; }> ? Readonly<{ brandKeys: '>=0' | '> -2^16' | '> -2^32' | '>= -2^15' | '>= -2^31'; brandFalseKeys: 'NaNValue'; }> : never) | (C extends Readonly<{ positive: true; }> ? Readonly<{ brandKeys: '>=0' | '!=0' | '> -2^16' | '> -2^32' | '>= -2^15' | '>= -2^31'; brandFalseKeys: '<=0' | 'NaNValue'; }> : never) | (C extends Readonly<{ nonPositive: true; }> ? Readonly<{ brandKeys: '< 2^15' | '< 2^16' | '< 2^31' | '< 2^32' | '<=0'; brandFalseKeys: 'NaNValue'; }> : never); type DefaultValueWhenNonZeroIsOn = C extends Readonly<{ nonZero: true; }> ? NonZeroNumber : NumberType; type DefaultValueWhenNegativeIsOn = C extends Readonly<{ negative: true; }> ? NegativeNumber : NumberType; type DefaultValueWhenNonNegativeIsOn = C extends Readonly<{ nonNegative: true; }> ? NonNegativeNumber : NumberType; type DefaultValueWhenPositiveIsOn = C extends Readonly<{ positive: true; }> ? PositiveNumber : NumberType; type DefaultValueWhenNonPositiveIsOn = C extends Readonly<{ nonPositive: true; }> ? NonPositiveNumber : NumberType; type NonZeroNumber = NumberType extends N ? NumberType : IsZero extends true ? never : N; type NegativeNumber = NumberType extends N ? NumberType : IsNegative extends true ? N : never; type NonNegativeNumber = NumberType extends N ? NumberType : IsNonNegative extends true ? N : never; type PositiveNumber = NumberType extends N ? NumberType : IsPositive extends true ? N : never; type NonPositiveNumber = NumberType extends N ? NumberType : IsNonPositive extends true ? N : never; type IsZero = `${N}` extends '0' ? true : false; type IsNonZero = IsZero extends true ? false : true; type IsNegative = `${N}` extends `-${string}` ? true : false; type IsNonNegative = IsNegative extends true ? false : true; type IsPositive = BoolAnd, IsNonNegative>; type IsNonPositive = BoolNot>; export {}; //# sourceMappingURL=number.d.mts.map