8000 Bug: [prefer-nullish-coalescing] <internal error when linting on binary expression (||) with destruct tuple and object with rename property> · Issue #8261 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content
Bug: [prefer-nullish-coalescing] <internal error when linting on binary expression (||) with destruct tuple and object with rename property> #8261
Closed
@sasurau4

Description

@sasurau4

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.3.3&fileType=.tsx&code=PTAEEkDNQTwewK6gMZwLZoKYDsAuoBLbUSOAGzLgHciBzUOAJ1AEMATNu0AAxYGcUcbH1zdQuOKEaZcCRsQBuLMgkwNopOABpQAQQqEBAeQDSAWABQIcTAAOagGJxJAXlABtAEbOymFth0Ab1BKdjoALlBvcj9iAF8AXQBuS2tIBGxkXAIhEmcACgBKSKdJQNSwUCkZOWJ3SGU%2BTCCQuDDsWkiGsibQRIq%2By0t0zOzczSLQcosq6Vl5D26moNDODq7GzH6LOKGLVGF8D08WRhW2tc7WRNA3CcK9g5Eo25JNyyf8ZFelzA%2BhZ6rLhuFigAA%2BYJeEJQSSAA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Y6RAM0WlqYSNkAC1pkA9gEMkyMswDm6KL2jjokcGAC%2BILUA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eFYDAruuGAL4g9A&tokens=false

Repro Code

// If you comment in following or adding `as const` to return value of foo, All is OK
// type Foo = [boolean, { loading: boolean }];
// function foo(): Foo {
//   return [false, { loading: false }]
// }

function foo() {
  return [false, {loading: false}]
}

const  [bar, {loading: a}] = foo()

const b = false
const c = false
const loading = a || b || c;

ESLint Config

module.exports = {
  "rules": {
    "@typescript-eslint/prefer-nullish-coalescing": "error"
  }
}

tsconfig

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

Expected Result

No lint and internal errors

Actual Result

Following internal error happened

TypeError: Cannot read properties of undefined (reading 'some')
Occurred while linting /input.tsx:15
Rule: "@typescript-eslint/prefer-nullish-coalescing"
    at LogicalExpression[operator = "||"] (https://typescript-eslint.io/sandbox/index.js:143:58720)

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