You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.Code Sandbox with a minimal reproduction case
https://www.typescriptlang.org/play?target=9&jsx=0&module=7#code/JYWwDg9gTgLgBAbziAhjAxgCzgXzgMyghDgCIYBnAWjDRgFMoA7UgbgCh36mBXEgFUzAmAc34BPMPUTs4cAGIBJAEoBlfgBpZcVQFEAwgHkAcgBF2OTsIZR8KdNPnAoFGIOEiZcmJPoAuOHdRCSkAOiU1fg5LdmtGOwcdenQIJgATIM8EbR8pAMyQ+lC9IzNozlzpTLgAXgVnV2qAHySU9MyOdjTkgBsUKGk21zh4fKFRTtQMTAAKGABKbVCAd2AYWaRKsY9C8JV1XA0CWoA+OCGIHqKeiBEZ0nwGmFJ5xbkVtY2R323g32KDCZTIdjjUzhcrqEbndSBRkqk0i83nBQvQAB6YFA8VzAABu9Bm8w4QA
Workaround
Defining the enum values as
string
fixes the problem. Defining them asnumber
(explicitly), doesn't.With string: https://www.typescriptlang.org/play?target=9&jsx=0&module=7#code/JYWwDg9gTgLgBAbziAhjAxgCzgXzgMyghDgCIYBnAWjDRgFMoA7UgbgCh36mBXEgFUzAmAc34BPMPUTs4cAGIBJAEoBlfnAC8ZJWv4B9fgAlFAOQDihgJoAFAKKkANLLiq7AYQDypgCJaybl6+hiYW1vak7DicwgxQ+Cjo0vLAUBQwgsIiMnIwkvQAXHCZohJSAHS66hzR7LGMCUmu9OgQTAAmJdkILnlSRV1l9OWB3j41nH3SXf4paRlConAAPs2tHV0c7O0tADYoUNLr6XDwA4siW6gYmAAUMACULuUA7sAwd0hT51lDlSrqXCOAhaAB8cGOEF2w12EBEt1I+FS6VIDyecle70+p3yP1K+RGHjGQJBmnBkOh5Vh8NIFBabXaqPRcHK9AAHpgUDx0sAAG70W4PDhAA
Versions
Somewhat offtopic
This library is impressive! Thanks for building it.
The text was updated successfully, but these errors were encountered: