Skip to content

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

@haines

Description

@haines

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=.ts&code=JYOwLgpgTgZghgYwgAgGIHt0GdkG8BQyyARnFAPwBcyIArgLbHT4C%2B%2B%2BC6IWYyMmWahmwBtALrIAvMnEBudv2wA6GABs4YALJwADgAo9uEmSnIALACZkLAJRSAfMag35QA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tmUSWWS0AJogBmAQwR1xAygHMmAW0Qt0URNGgdokADThseIqWQVqdBszawmAIw42htZfgAWHIWsgatOgwF8QfyA&tsconfig=N4XyA&tokens=false

Repro Code

interface Foos {
  bar?: number
}

const foos: Foos[] = [];

foos.flatMap(({ bar = 42 }) => bar);

ESLint Config

module.exports = {
  "rules": {
    "@typescript-eslint/no-useless-default-assignment": "error",
    "@typescript-eslint/unbound-method": "error"
  }
}

tsconfig

{}

Expected Result

No errors.

Actual Result

Linting fails with

TypeError: Cannot read properties of undefined (reading 'flags')

Additional Info

This seems to only occur if both @typescript-eslint/no-useless-default-assignment and @typescript-eslint/unbound-method are enabled. flatMap produces the error but map does not.

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