8000 [no-shadow.ignoreTypeValueShadow] false positive against imported types · Issue #3862 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

[no-shadow.ignoreTypeValueShadow] false positive aga 8000 inst imported types #3862

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

Closed
3 tasks done
ghost opened this issue Sep 9, 2021 · 1 comment · Fixed by #3868
Closed
3 tasks done

[no-shadow.ignoreTypeValueShadow] false positive against imported types #3862

ghost opened this issue Sep 9, 2021 · 1 comment · Fixed by #3868
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@ghost
Copy link
ghost commented Sep 9, 2021
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
   "@typescript-eslint/no-shadow": [
      "error",
      { "ignoreTypeValueShadow": true }
    ]
  }
}
import type { foo } from './foo';
type bar = number;

// 'foo' is already declared in the upper scope
// 'bar' is fine
function doThing(foo: number, bar: number) {}

tsconfig:

{
  "extends": "@tsconfig/node16/tsconfig.json",
  "compileOnSave": true,
  "compilerOptions": {
    "baseUrl": "./",
    "composite": true,
    "esModuleInterop": true,
    "exactOptionalPropertyTypes": true,
    "experimentalDecorators": true,
    "forceConsistentCasingInFileNames": true,
    "importHelpers": true,
    "isolatedModules": true,
    "module": "ESNext",
    "moduleResolution": "node",
    "noEmit": true,
    "noImplicitAny": true,
    "noImplicitOverride": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noUncheckedIndexedAccess": true,
    "noUnusedLocals": true,
    "paths": {
      "@applications/*": ["src/applications/*"],
      "@modules/*": ["src/modules/*"],
      "package.json": ["package.json"]
    },
    "resolveJsonModule": true,
    "rootDirs": [".", "src/modules/seams"],
    "strict": true,
    "typeRoots": ["src/modules/@types", "node_modules/@types"]
  },
  "exclude": ["**/node_modules", "**/build", "**/dist"],
  "include": ["src/**/*", "./*", "./*.json", "config/*", "config/*.json"]
}

Expected Result

rule should ignore imported types just like it ignores types defined in the file

Versions

package version
@typescript-eslint/eslint-plugin 4.31.0
@typescript-eslint/parser 4.31.0
TypeScript 4.4.2
ESLint 7.32.0
node 16.8.0
@ghost ghost added package: eslint-plugin Issues related to @typescri 9B3A pt-eslint/eslint-plugin triage Waiting for team members to take a look labels Sep 9, 2021
@bradzacher
Copy link
Member

This occurs because "type only" imports are actually treated as both a type and value by TS.
This is done so that typeof foo works properly. It's a little bit weird, I know.
The rule should have special-case handling for this, however.

@bradzacher bradzacher added bug Something isn't working and removed triage Waiting for team members to take a look labels Sep 10, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant
0