From cebcfe640ec56535bc565dabad6fb4b90db60afc Mon Sep 17 00:00:00 2001 From: Jonathan Skeate Date: Wed, 27 Mar 2019 19:04:58 -0400 Subject: [PATCH] fix(eslint-plugin): no-type-alias: fix typeof alias erroring (#380) --- packages/eslint-plugin/src/rules/no-type-alias.ts | 1 + packages/eslint-plugin/tests/rules/no-type-alias.test.ts | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/packages/eslint-plugin/src/rules/no-type-alias.ts b/packages/eslint-plugin/src/rules/no-type-alias.ts index c15795773a0..890e6b04aa5 100644 --- a/packages/eslint-plugin/src/rules/no-type-alias.ts +++ b/packages/eslint-plugin/src/rules/no-type-alias.ts @@ -108,6 +108,7 @@ export default util.createRule({ AST_NODE_TYPES.TSArrayType, AST_NODE_TYPES.TSTypeReference, AST_NODE_TYPES.TSLiteralType, + AST_NODE_TYPES.TSTypeQuery, ]; type CompositionType = TSESTree.TSUnionType | TSESTree.TSIntersectionType; diff --git a/packages/eslint-plugin/tests/rules/no-type-alias.test.ts b/packages/eslint-plugin/tests/rules/no-type-alias.test.ts index df42dd0f082..d34cb9957b8 100644 --- a/packages/eslint-plugin/tests/rules/no-type-alias.test.ts +++ b/packages/eslint-plugin/tests/rules/no-type-alias.test.ts @@ -364,6 +364,14 @@ type Foo = { }, ], }, + { + code: 'type Foo = typeof bar;', + options: [{ allowAliases: 'always' }], + }, + { + code: 'type Foo = typeof bar | typeof baz;', + options: [{ allowAliases: 'in-unions' }], + }, ], invalid: [ {