Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I haveread the FAQ and my problem is not listed.
Repro
{"rules": {"@typescript-eslint/switch-exhaustiveness-check":"warn" }}
typeDay=string;// or numberconstday='Monday'asDay;letresult=0;switch(day){case'Monday':{result=1;break;}}
or
typeDay=any;// or unknown, or a JS variable outside of a TS contextconstday='Monday'asDay;letresult=0;switch(day){case'Monday':{result=1;break;}}
Expected Result
I would expect to see an error message compatible with thedefault-case
ESLint rule, indicating that the switch-exhaustiveness-check rule is invalidated because the expression is not a union type.
Actual Result
No error message.
Additional Info
Essentially, I think the best of both worlds is to just have the predictable functionality of thedefault-case
rule operate normally except in the event that a switch statement's expression is a union type. Today, there doesn't seem to be any way for the two rules to operate in tandem. Adding this functionality might be a breaking change, but I'm honestly a bit curious how controversial it would be.