Closed
Description
It is incredibly easy to make a copy/paste error for case
clauses in a switch
statement.
switch (node.kind) {
// ...
case SyntaxKind.TupleType:
// Do something with tuple types.
case SyntaxKind.TupleType:
// Do something with union types.
// ...
}
While it is easily arguable that non-exhaustive cases can be allowed in TypeScript, there is no reason not to report duplicated cases.
"Obvious" semantics for case
clauses in a single switch
statement are as follows:
- Report when named entities with identical symbols are handled.
- Report when equal string literals are handled.
- Report when equal numeric literals (even 0.0 and 0) are handled.
- Report when
null
is handled more than once. - Report when
undefined
is handled more than once.
One interesting question is whether exhaustive cases for an enum should report an error when there is a default
clause.