Skip to content

Commit

Permalink
fix(eslint-plugin): [no-type-alias] unhandled type
Browse files Browse the repository at this point in the history
Fixes #720
  • Loading branch information
ankeetmaini committed Jul 29, 2019
1 parent f953cbd commit 24edd61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 0 additions & 3 deletions packages/eslint-plugin/src/rules/no-type-alias.ts
Expand Up @@ -239,9 +239,6 @@ export default util.createRule<Options, MessageIds>({
) {
reportError(type.node, type.compositionType, isTopLevel, 'Aliases');
}
} else {
// unhandled type - shouldn't happen
reportError(type.node, type.compositionType, isTopLevel, 'Unhandled');
}
}

Expand Down
12 changes: 12 additions & 0 deletions packages/eslint-plugin/tests/rules/no-type-alias.test.ts
Expand Up @@ -7,6 +7,18 @@ const ruleTester = new RuleTester({

ruleTester.run('no-type-alias', rule, {
valid: [
{
code: 'type Foo = string | [number, number];',
options: [{ allowAliases: 'in-unions' }],
},
{
code: 'type Foo = string & [number, number];',
options: [{ allowAliases: 'in-intersections' }],
},
{
code: 'type Foo = string & [number, number] | [number, number, number];',
options: [{ allowAliases: 'in-unions-and-intersections' }],
},
{
code: "type A = 'a' & ('b' | 'c');",
options: [{ allowAliases: 'always' }],
Expand Down

0 comments on commit 24edd61

Please sign in to comment.