TypeScript: new value enum skips incomplete switch
After adding a new order status, one branch of UI displays an empty text, although build passes. The switch code does not fully check all variants of the union type and the new value passes unnoticed.
How to identify the source of the problem
Browse the status union definition and all features mapping status into labels and permissions. Check the default case and see if it returns silent undefined for unknown value.
Compare the message from the console with the result of the production compilation and the condition after the page has been refreshed.
Repair steps
Use a comprehensive check with the Never parameter in the default branch or assertNever function. Add a test to cover all acceptable statuses and behavior with unexpected API data.
How to Test Solution
Adding a new status requires improving mapping in typecheck, and current values give the right labels.
Security and restrictions
Do not enter the default label “OK” for unknown status because it maskes the flow error.