Skip to content

Commit

Permalink
fix(eslint-plugin): [unbound-method] Allow typeof expressions (Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
scottohara authored and bradzacher committed Aug 27, 2019
1 parent 5603473 commit 344bafe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/eslint-plugin/src/rules/unbound-method.ts
Expand Up @@ -120,6 +120,9 @@ function isSafeUse(node: TSESTree.Node): boolean {
case AST_NODE_TYPES.TaggedTemplateExpression:
return parent.tag === node;

case AST_NODE_TYPES.UnaryExpression:
return parent.operator === 'typeof';

case AST_NODE_TYPES.TSNonNullExpression:
case AST_NODE_TYPES.TSAsExpression:
case AST_NODE_TYPES.TSTypeAssertion:
Expand Down
6 changes: 6 additions & 0 deletions packages/eslint-plugin/tests/rules/unbound-method.test.ts
Expand Up @@ -97,6 +97,12 @@ instane.boundStatic && 0;
ContainsMethods.boundStatic ? 1 : 0;
ContainsMethods.unboundStatic ? 1 : 0;
typeof instance.bound === 'function';
typeof instance.unbound === 'function';
typeof ContainsMethods.boundStatic === 'function';
typeof ContainsMethods.unboundStatic === 'function';
`,
`interface RecordA {
readonly type: "A"
Expand Down

0 comments on commit 344bafe

Please sign in to comment.