Replace string typing with enums or unions
Replace raw string discriminators with TypeScript unions, enums, or sealed classes for compile-time safety. Adds exhaustive checks and usage documentation.
Preview
Copy prompt
The following code uses raw string literals as type discriminators, making it impossible to catch typos at compile time: [Paste code]. Replace them with a [TypeScript union type / sealed enum / discriminated union / sealed class] appropriate to [Language]. Update every usage site to use the new typed values, add exhaustive switch or match checks where applicable, and add a brief comment documenting what each valid value represents.
More
Refactoring
Prompts
