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

no-shadow: false positive when importing type #550

Closed
OliverJAsh opened this issue May 23, 2019 · 3 comments
Closed

no-shadow: false positive when importing type #550

OliverJAsh opened this issue May 23, 2019 · 3 comments
Labels
bug Something isn't working package: parser Issues related to @typescript-eslint/parser scope analyser Issues that are caused by bugs/incomplete cases in the scope analyser

Comments

@OliverJAsh
Copy link
Contributor

What code were you trying to parse?

This works fine, as expected.

type Consumer = {};
const fn = (Consumer: Consumer) => {};

However, if the type is imported, this errors unexpectedly:

import { Consumer } from './other';

// ESLint error: 'Consumer' is already declared in the upper scope.
const fn = (Consumer: Consumer) => {};

What did you expect to happen?
No error, because there is no shadowing. Here I am defining a parameter that has the same name as the type, but this doesn't count as shadowing, because one is a type, one is a value.

What actually happened?
Unexpected error.

Versions

package version
@typescript-eslint/parser 1.90
TypeScript 3.4.1
ESLint 5.16.0
node 8.15.1
npm 6.4.1
@OliverJAsh OliverJAsh added package: parser Issues related to @typescript-eslint/parser triage Waiting for maintainers to take a look labels May 23, 2019
@bradzacher bradzacher added bug Something isn't working scope analyser Issues that are caused by bugs/incomplete cases in the scope analyser and removed triage Waiting for maintainers to take a look labels May 23, 2019
@mcmar
Copy link

mcmar commented Jun 12, 2019

I'm not sure if this is related to this issue or not. The no-shadow rule also is triggered by typescript module augmentation:

import { pathUtils } from 'react-navigation';

declare module 'react-navigation' {
  // this sets off no-shadow rule
  const pathUtils: {
    urlToPathAndParams(url: string, uriPrefix: string): { path: string; params: {} };
  };
}

@frenic
Copy link

frenic commented Nov 27, 2019

This also happens on enums:

import { Consumer } from './other';

enum UserType {
  Customer, // ESLint error: 'Customer' is already declared in the upper scope
}
package version
@typescript-eslint/parser 2.7.0
TypeScript 3.7.2
ESLint 6.6.0
node 12.4.0
yarn 1.15.2

@bradzacher bradzacher added this to the scope analysis rewrite milestone Apr 6, 2020
@bradzacher
Copy link
Member

Merging into #1856

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: parser Issues related to @typescript-eslint/parser scope analyser Issues that are caused by bugs/incomplete cases in the scope analyser
Projects
None yet
Development

No branches or pull requests

4 participants