8000 Bug: [unified-signatures] overloads with differently named parameters are still reported when other parameters are present · Issue #6832 · typescript-eslint/typescript-eslint · GitHub 8000
[go: up one dir, main page]

Skip to content
Bug: [unified-signatures] overloads with differently named parameters are still reported when other parameters are present #6832
Closed
@vostrnad

Description

@vostrnad

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=5.0.2&sourceType=module&code=C4TwDgpgBAqgdgS2AOQIYFtoF4oHJ0IA2hCAzhAMYD2cAJqblAD57nV0PN4FwCuwEBgFgAUKIqFUpUlAAqCTFADeoqFDAAnBADdUAqBoipaNQiCi7CvCAC4ofdACMIG0aqjtSwDbwrAqGgAUltYA-HYOzhoAlMruasAAFmQAdCHYFqhW0KGhUAAiehApcFQA7oHR7gC+biJqYLyOJBRQxrSBBMRkEbxOLtF28pjujc0Ire3BWda9-RoANFC8iMB28EhomINyChB1DU0tbbQd6XNRSytI4bCrWxA7w9Aq9WpQhBDAUOi8hMAIMAkFwXFwHd6kMpICiJKCBa7AWKvd7vChSaArWgQABmCDgEFoNniqPR3CIJDYNHouCJbxRal+-0BwI0UBwAEZiSjHIZUABrLkeUm4SkcGmChl-AFAhAuNlQdkABmVEqgPKMArpJPIZL4AgYtPp70Z0pZ8oAbMqVVrubzNSjamItYZgLwNHB7BAyrtMIEkql0lAANSZbJQABUPylzNlMRqokdQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6WJygM0sQBNaySgHMmAQ3yxoKdGADa4bBACMAGkVKsS7JBFMA9tIAi3Lomkt4hAHJiAtvwAKY6PcT5zqDPjiIN2AF9-AF1FIICgA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

type UnitName = 'milliseconds' | 'seconds' | 'minutes'

class Time {
  private readonly value: number

  constructor(value?: number) {
    this.value = value ?? Date.now()
  }

  public add(millis: number): Time
  public add(value: number, unit: UnitName): Time

  public add(value: number, unit?: UnitName): Time {
    let multiplier: number

    switch (unit) {
      case undefined:
      case 'milliseconds':
        multiplier = 1
        break
      case 'seconds':
        multiplier = 1000
        break
      case 'minutes':
        multiplier = 60000
        break
    }

    return new Time(this.value + value * multiplier)
  }
}

ESLint Config

module.exports = {
  "rules": {
    "@typescript-eslint/unified-signatures": [
      1,
      {
        "ignoreDifferentlyNamedParameters": true
      }
    ]
  }
}

tsconfig

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

Expected Result

No error should be reported, at least with the ignoreDifferentlyNamedParameters option turned on, since the overloads I'm supposed to combine have a differently named first parameter.

Actual Result

I get the following ESLint warning:

These overloads can be combined into one signature with an optional parameter. 11:29 - 11:43

Additional Info

No response

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

      0