`exhaustive` doesn't work when the conditions use an enum with numeric values
Author: alcuadradoCreated Jul 23, 2023Updated Dec 14, 2025
Describe the bug
If you try to match over a type who's discriminating field is an enum with numeric values, exhaustive() seems to get lost and produces a type error when it's not needed.
Workaround
Defining the enum values as string fixes the problem. Defining them as number (explicitly), doesn't.
Versions
- TypeScript version: 5.1.6
- ts-pattern version: 5.0.4
- environment: node 20.5.0, ts's playground, and anything I tried.
Somewhat offtopic
This library is impressive! Thanks for building it.
Source: gvergnaud/ts-pattern