Skip to content

Bug: [no-useless-default-assignment] Cannot read properties of undefined (reading 'getParameters') #11849

@ulrichstark

Description

@ulrichstark

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.9.2&fileType=.tsx&code=C4TwDgpgBAshBOBzaBeKAjA9pgNhAhgHZQA%2BUAFOQJaEDGmAtjYgFxQDOw8zA2gLoBKKCgB8UAG6YqAEwEBuAFAL6hTlDC4qtEGwDeUBgmRs4SaAF9hUXQqgGjENtTqNmbTt0KJ%2BV-kNHWtnZQNPRMXop25gA0CuZyQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tmUSWWS0AJogBmAQwR1xAygHMmAW0Qt0URNGgdokcGAC%2BIfUA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

type Merge = boolean | ((incoming: string[]) => void);

const policy: { merge: Merge } = {
  merge: (incoming: string[] = []) => {
    incoming;
  },
};

ESLint Config

{
  "rules": {
    "@typescript-eslint/no-useless-default-assignment": "error",
  }
}

tsconfig

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

Expected Result

Don't crash

Actual Result

TypeError: Cannot read properties of undefined (reading 'getParameters')
    at AssignmentPattern (https://typescript-eslint.io/sandbox/index.js:1:1970743)
    at https://typescript-eslint.io/sandbox/index.js:1:1519135
    at https://typescript-eslint.io/sandbox/index.js:1:1457396
    at Array.forEach (<anonymous>)
    at SourceCodeVisitor.callSync (https://typescript-eslint.io/sandbox/index.js:1:1457384)
    at https://typescript-eslint.io/sandbox/index.js:1:1507727
    at Array.forEach (<anonymous>)
    at l.traverseSync (https://typescript-eslint.io/sandbox/index.js:1:1507712)
    at se (https://typescript-eslint.io/sandbox/index.js:1:1519263)
    at Linter.ue (https://typescript-eslint.io/sandbox/index.js:1:1524589) 4:11 - 4:34

Additional Info

Originally reported by @simPod in #11720 (comment).

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