ts-type-forge
    Preparing search index...

    Type Alias ExcludeSmallInt<N, MaxIndex>

    ExcludeSmallInt: RelaxedExclude<N, SmallInt<"", MaxIndex>>

    Removes small integer literals from an integer type enhanced with WithSmallInt. Useful for converting back to pure branded types.

    Type Parameters

    • N extends IntWithSmallInt

      Integer type with small literals to remove from

    • MaxIndex extends number = TSTypeForgeInternals_SmallIntIndexMax

      Maximum absolute value of literals to remove (default: 40)

    The branded type without literal values

    type Count = WithSmallInt<Uint>; // 0 | 1 | ... | 39 | Uint
    type PureCount = RemoveSmallInt<Count>; // Uint

    const toLargeCount = (n: Count): RemoveSmallInt<Count> => {
    if (typeof n === 'number') {
    return (n + 1000) as Uint; // Convert small to large
    }
    return n;
    };