ts-type-forge
    Preparing search index...

    Type Alias MonthEnum

    MonthEnum: Exclude<Index<13>, 0>

    Represents the months of the year using 1-based indexing. A union of integer literals from 1 (January) to 12 (December).

    This follows the common human-readable convention where January = 1, unlike JavaScript's Date object which uses 0-based month indexing.

    const getMonthName = (month: MonthEnum): string => {
    const names = [
    'Jan',
    'Feb',
    'Mar',
    'Apr',
    'May',
    'Jun',
    'Jul',
    'Aug',
    'Sep',
    'Oct',
    'Nov',
    'Dec',
    ];
    return names[month - 1] ?? ''; // Convert to 0-based for array access
    };

    const january = 1 satisfies MonthEnum;
    const december = 12 satisfies MonthEnum;
    // const invalid = 13 satisfies MonthEnum; // Error: not assignable to MonthEnum