Skip to content

Bug: [unified-signatures] Crash in rule implementation #6882

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
4 tasks done
danielrentz opened this issue Apr 11, 2023 · 1 comment · Fixed by #6940
Closed
4 tasks done

Bug: [unified-signatures] Crash in rule implementation #6882

danielrentz opened this issue Apr 11, 2023 · 1 comment · Fixed by #6940
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@danielrentz
Copy link

danielrentz commented Apr 11, 2023

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.9.3&sourceType=module&showAST=es&code=KYDwDg9gTgLgBAQwEYGcZQQY3pgNglFOAFWDTgG8BYAKDkVXS3gFtgYALCAEwAoAzfAHMAXHHQBXYAEoxAOwkskwKAG5a9ZGgzY4bTj16y42gJZyh6mgF9aQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6WJygM0sQBNaySgHMmAQ3yxoKdGADakRNGgB7aJAA0mKCKZrEAEW5cliFvEIA5MQFt+ABTHRbifEtQZ8cRGAC+AXXA-EF8gA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

export abstract class Test {
    abstract method(flag: true): number;
    abstract method(): string;
}

ESLint Config

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

tsconfig

{
  "compilerOptions": {
    "strict": true
  }
}

Expected Result

Linter should pass.

Actual Result

Oops! Something went wrong! :(

ESLint: 8.38.0

TypeError: Cannot read properties of undefined (reading 'type')
Occurred while linting test.ts:13
Rule: "@typescript-eslint/unified-signatures"
    at signaturesCanBeUnified (./node_modules/@typescript-eslint/eslint-plugin/dist/rules/unified-signatures.js:146:58)
    at compareSignatures (./node_modules/@typescript-eslint/eslint-plugin/dist/rules/unified-signatures.js:133:18)
    at ./node_modules/@typescript-eslint/eslint-plugin/dist/rules/unified-signatures.js:124:35
    at forEachPair (./node_modules/@typescript-eslint/eslint-plugin/dist/rules/unified-signatures.js:311:21)
    at checkOverloads (./node_modules/@typescript-eslint/eslint-plugin/dist/rules/unified-signatures.js:120:17)
    at checkScope (./node_modules/@typescript-eslint/eslint-plugin/dist/rules/unified-signatures.js:328:30)
    at ruleErrorHandler (./node_modules/eslint/lib/linter/linter.js:1077:28)
    at ./node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (./node_modules/eslint/lib/linter/safe-emitter.js:45:38)

Additional Info

Happens only with option "ignoreDifferentlyNamedParameters".

@danielrentz danielrentz added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Apr 11, 2023
@bradzacher
Copy link
Member

This crash specifically occurs if there is a an overload as the 2nd+ definition that has fewer parameters than an earlier definition AND the ignoreDifferentlyNamedParameters option is turned on.

Probably needed some additional test cases for #6877? cc @JoshuaKGoldberg / @NotWoods

@bradzacher bradzacher added good first issue Good for newcomers accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Apr 11, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants