Enhancement: [switch-exhaustiveness-check] require default cases for non-union types #7862
Closed
4 tasks done
Labels
duplicate
This issue or pull request already exists
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Link to the rule's documentation
https://typescript-eslint.io/rules/switch-exhaustiveness-check/
Description
I propose that the
switch-exhaustiveness-check
checksswitch
statements that operate on non-union-types and require them to have a default case to ensure they are exhaustive.Fail
Pass
Additional Info
Since it would break projects that have the
switch-exhaustiveness-check
enabled, but don't have all their switch statements fully exhaustive, this should probably locked behind a default false option. Maybe this could be turned on by default with the next major version.This option can not be replaced with
default-case
due to #7539.default
case on an already exhaustiveswitch
#7539Originally searched for during:
The text was updated successfully, but these errors were encountered: