Skip to content

[no-unused-vars] False positive: export with in keyof #2615

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
OriginLive opened this issue Sep 30, 2020 · 4 comments
Closed
3 tasks done

[no-unused-vars] False positive: export with in keyof #2615

OriginLive opened this issue Sep 30, 2020 · 4 comments
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin unable to repro issues that a maintainer was not able to reproduce

Comments

@OriginLive
Copy link

  • 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

// file 1

export type FieldDefinition = {
  [key: string]: string[];
};

// file 2

interface FruitsFormDefinition {
  apple: string;
  orange: string;
}

export type FruitsFieldDefinition = { [K in keyof FruitsFormDefinition]: FieldDefinition[string] };

export const fruitsFieldDefiniton: FruitsFieldDefinition = {
  apple: [],
  orange: ['isRequired'],
};

tsconfig:

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": false,
    "skipLibCheck": false,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noImplicitAny": true,
    "downlevelIteration": true,
    "noEmit": true,
    "jsx": "react",
    "typeRoots": [
      "./node_modules/@types",
      "./src/@types"
    ]
  },
  "include": [
    "src"
  ],
  "exclude": [
    "config-overrides.js"
  ]
}

Expected Result

no errors

Actual Result

Line 32:37: 'K' is defined but never used. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars

Additional Info

Also getting is already declared in the upper scope no-shadow
not sure it's related or might go away with the fix

Versions

package version
@typescript-eslint/eslint-plugin 4.3.0
@typescript-eslint/parser 4.3.0
TypeScript 4.0.3
@OriginLive OriginLive added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Sep 30, 2020
@OriginLive
Copy link
Author

another example of same error

export type FormValues<T> = {
  [K in keyof T]: FormValue;
};

@yeonjuan
Copy link
Contributor

@OriginLive Hi :) I cannot reproduce it. Could you share your eslint config file or way to repro it?

@bradzacher bradzacher added working as intended Issues that are closed as they are working as intended awaiting response Issues waiting for a reply from the OP or another party unable to repro issues that a maintainer was not able to reproduce and removed triage Waiting for team members to take a look working as intended Issues that are closed as they are working as intended labels Sep 30, 2020
@bradzacher
Copy link
Member

@OriginLive
Copy link
Author

just tried it again today and it seems to work. No idea what changed

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 1, 2020
@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Jan 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin unable to repro issues that a maintainer was not able to reproduce
Projects
None yet
Development

No branches or pull requests

3 participants