Skip to content

Commit

Permalink
fix(eslint-plugin): [no-extra-parens] Fix crash default switch case c…
Browse files Browse the repository at this point in the history
…rash

Fixes #509
  • Loading branch information
bradzacher committed May 13, 2019
1 parent d9e5f15 commit 5ec2b32
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-extra-parens.ts
Expand Up @@ -200,7 +200,7 @@ export default util.createRule<Options, MessageIds>({
}
},
SwitchCase(node) {
if (node.test.type !== AST_NODE_TYPES.TSAsExpression) {
if (node.test && node.test.type !== AST_NODE_TYPES.TSAsExpression) {
return rules.SwitchCase(node);
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/tests/rules/no-extra-parens.test.ts
Expand Up @@ -146,7 +146,7 @@ throw 1;
const x = !(1 as 1);
const x = (1 as 1)++;
function *x() { yield (1 as 1); yield 1; }
switch (foo) { case 1: case (2 as 2): }
switch (foo) { case 1: case (2 as 2): break; default: break; }
`,
options: [
'all',
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-estree/src/ts-estree/ts-estree.ts
Expand Up @@ -928,7 +928,7 @@ export interface Super extends BaseNode {

export interface SwitchCase extends BaseNode {
type: AST_NODE_TYPES.SwitchCase;
test: Expression;
test: Expression | null;
consequent: Statement[];
}

Expand Down

0 comments on commit 5ec2b32

Please sign in to comment.