Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scope-manager): correct analysis of inferred types in conditional types #2537

Merged
merged 5 commits into from Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/eslint-plugin/tests/rules/no-shadow.test.ts
Expand Up @@ -11,6 +11,14 @@ const ruleTester = new RuleTester({

ruleTester.run('no-shadow TS tests', rule, {
valid: [
// nested conditional types
`
export type ArrayInput<Func> = Func extends (arg0: Array<infer T>) => any
? T[]
: Func extends (...args: infer T) => any
? T
: never;
`,
`
function foo() {
var Object = 0;
Expand Down
4 changes: 3 additions & 1 deletion packages/scope-manager/src/referencer/TypeVisitor.ts
Expand Up @@ -94,9 +94,11 @@ class TypeVisitor extends Visitor {
// which are only accessible from inside the conditional parameter
this.#referencer.scopeManager.nestConditionalTypeScope(node);

this.visitChildren(node);
this.visitChildren(node, ['falseType']);
dinofx marked this conversation as resolved.
Show resolved Hide resolved

this.#referencer.close(node);

this.visit(node.falseType);
}

protected TSConstructorType(node: TSESTree.TSConstructorType): void {
Expand Down