Skip to content

Bug: [no-shadow] ignoreFunctionTypeParameterNameValueShadow = true false positive on function interface dec #6098

Closed
@kavsingh

Description

@kavsingh

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=4.8.4&sourceType=module&code=KYDwDg9gTgLgBAYwgOwM7xHAvHADAbgChRJZEV04BPbPIwgegbmQjmCimgBo4B3aAGtUcAIYiSwBDGAATYuGjwYVMMDgBJWcGTwcAHgAqAPgAUIAFxxDASmzHr9JizYcuUXgKjCxE8FJl5EiU4AEtdDgAzUQR1AHkAIwArOABvQjgxWVkrcytkAFcAWwSOXip84tKoOywHQpKOIgBfQgVSeCQ0eFQIIuAAMQLkBCt0zOc3aDgAchAZsJFRABsoYFFZGm0EZdE12TDkOBgAC3UCsDUoOFQkNQy4Sc5p1nhJaTkHozNLaxsrQxECbMKbXOYLUJLVbrTZwba7faHY5nOAXK43O7AB5PdyzKgQqFrDZbKQIuRI07nS4cDEQe7A9jPa6vdj+D7yTLfPLWcqVRo1AFwAA+LCqTUIzVoplEvASAH4+dVag4EnA5XKxPRgmRwjIoNFYpohiM0tiQUzZvNFmJocS4aS9uTwsiqejbnSsQzQS43mzAl8TNzbACgY9zbjwdaVkTYfDHQdnZTUdTru76WHGRH8VHbbGHYjEyi0TS056M96We9-ZzA79DLzRfz-tZhY3qi02trlKp1IZjQhaONyxbI5CbTGSTt4xSiynaemcS8IL61OyAz8Ac3AWbM9NR4SYZOyQmjkni6nMTvvTNs2Po4f7VOC6fZ27L16LZW-Z8axuedRFQ4LdWwadsJTaIA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1uQAsBDACYcA7ujABtcNhyJo0DtEgAaKdKzTskSgHNO0RABUSiAGp94sRAGV+Q0RgBm55IhUbNOvYgBisJmXxKDiYjUgAFPmg+AFtEfFkAORjTc0sbQRExfDhEVWwAXzyAXSlCwqA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

export const x = 0;
export const y = 0;

// no error, works as expected
export type Ident = <T>(x: T) => T;

// no error, works as expected
export interface Obj {
  add: (x: number, y: number) => number;
}

export const someFunc: {
  // error 'x' is already declared in the upper scope
  // error not expected
  <T>(x: T): T;
  // error 'x' is already declared in the upper scope
  // error 'y' is already declared in the upper scope
  // error not expected
  <T>(x: T, y: number): T | number;
} = (a, b?: number) => b ?? a;

export interface IFunc {
  // error 'x' is already declared in the upper scope
  // error not expected
  <T>(x: T): T;
  // error 'x' is already declared in the upper scope
  // error 'y' is already declared in the upper scope
  // error not expected
  <T>(x: T, y: number): T | number;
}

export type TFunc = {
  // error 'x' is already declared in the upper scope
  // error not expected
  <T>(x: T): T;
  // error 'x' is already declared in the upper scope
  // error 'y' is already declared in the upper scope
  // error not expected
  <T>(x: T, y: number): T | number;
}

ESLint Config

module.exports = {
  "rules": {
    "@typescript-eslint/no-shadow": [
      "error",
      {
        "ignoreTypeValueShadow": false,
        "ignoreFunctionTypeParameterNameValueShadow": true
      }
    ]
  }
}

tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

Expected Result

with ignoreFunctionTypeParameterNameValueShadow set to true,
expected no errors when shadowing variables in function interface parameters

Actual Result

with ignoreFunctionTypeParameterNameValueShadow set to true,
received errors when shadowing variables in function interface parameters

Additional Info

was working as expected in v5.42.1, errors as of v5.43.0

Versions

package version
@typescript-eslint/eslint-plugin 5.44.0
@typescript-eslint/parser 5.44.0
TypeScript 4.8.4
ESLint 8.15.0
node web

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions