Skip to content

Commit

Permalink
fix(scope-manager): fix visiting TSAsExpression in assignment (#3355)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonjuan committed May 9, 2021
1 parent ddfab95 commit 87521a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/eslint-plugin/tests/eslint-rules/no-undef.test.ts
Expand Up @@ -139,6 +139,13 @@ function predicate(arg: any): asserts arg is T {
throw 'oops';
}
}
`,
`
interface ITest {
attr: string;
}
let test: unknown;
(test as ITest) = { attr: '' };
`,
{
code: `
Expand Down
2 changes: 1 addition & 1 deletion packages/scope-manager/src/referencer/Referencer.ts
Expand Up @@ -320,7 +320,7 @@ class Referencer extends Visitor {
case AST_NODE_TYPES.TSAsExpression:
case AST_NODE_TYPES.TSTypeAssertion:
// explicitly visit the type annotation
this.visit(left.typeAnnotation);
this.visitType(left.typeAnnotation);
// intentional fallthrough
case AST_NODE_TYPES.TSNonNullExpression:
// unwrap the expression
Expand Down

0 comments on commit 87521a0

Please sign in to comment.