ts-enum-util is a strictly typed utility library designed to enhance the usability and safety of TypeScript enums, as well as string and number literal union types. It provides two core functionalities: Enum Wrapper Utilities and Enum Value Visitor/Mapper. The Enum Wrapper offers type-safe methods for runtime inspection and manipulation of enums, such as retrieving keys, values, performing lookups with validation, and treating enums like arrays or maps. The Value Visitor/Mapper implements a visitor pattern, forcing exhaustive handling of all possible enum or literal union values, similar to a comprehensive switch statement, which helps prevent bugs from unhandled cases. The library is actively maintained, with the current stable version being 4.1.0, and new features or bug fixes are regularly released. Its key differentiators include strong compile-time type safety for enum operations and the exhaustive visitor pattern for robust code.
npm install ts-enum-utilVerified import paths — ran on the pinned version, not inferred.
Demonstrates importing the `$enum` utility, defining enums, and using wrapper methods like `getValues()`, `getKeys()`, `isValue()`, and the `visitValue()` pattern for exhaustive enum value handling.
Consult the `ts-enum-util` README for specific migration guidance, and refactor existing `ts-string-visitor` code to use `$enum.visitValue()` or `$enum.mapValue()` from `ts-enum-util`.
Upgrade to `ts-enum-util@4.0.1` or newer to ensure correct processing of all valid numeric enum values, including negative numbers and floats.
No direct code fix needed. Ensure your project explicitly declares its TypeScript dependency if strict versioning or specific tooling integration is required.
Refer to the 'Requirements' section in the `ts-enum-util` README for the exact supported TypeScript versions and adjust your project's TypeScript dependency accordingly.
Upgrade to `ts-enum-util@4.0.1` or newer to obtain fixes for handling non-positive integer enum values correctly.
Migrate your code from using `ts-string-visitor` to utilizing the integrated visitor/mapper functionality available through `$enum.visitValue()` or `$enum.mapValue()` from `ts-enum-util`.
Upgrade to `ts-enum-util@3.0.5` (or `2.0.5` for the `2.x` branch) or newer to benefit from corrected and type-safe definitions for these wrapper types.
No dependency data recorded yet.