Skip to content
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

Bug: [prefer-nullish-coalescing] TypeError: Cannot read properties of undefined (reading 'some') when left-hand-side is unknown #8276

Closed
4 tasks done
JoshuaKGoldberg opened this issue Jan 20, 2024 · 2 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@JoshuaKGoldberg
Copy link
Member

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=CYUwxgNghgTiAEYD2A7AzgF3gNyhAriAFzz4oDWKSA7igNwBQuBCAPq-AN4C%2BjQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Y6RAM0WlqYSNkAC1pkA9gEMkyMswDm6KL2jjokcGAC%2BILUA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

declare const value: unknown;
value || {};

ESLint Config

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

tsconfig

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

Expected Result

No crash. Perhaps a lint report.

Actual Result

TypeError: Cannot read properties of undefined (reading 'some')
Occurred while linting /input.tsx:2
Rule: "@typescript-eslint/prefer-nullish-coalescing"
    at LogicalExpression[operator = "||"] (https://typescript-eslint.io/sandbox/index.js:143:58720)
    at https://typescript-eslint.io/sandbox/index.js:106:2597
    at https://typescript-eslint.io/sandbox/index.js:100:32964
    at Array.forEach (<anonymous>)
    at Object.emit (https://typescript-eslint.io/sandbox/index.js:100:32953)
    at _x.applySelector (https://typescript-eslint.io/sandbox/index.js:41:22861)
    at _x.applySelectors (https://typescript-eslint.io/sandbox/index.js:41:23157)
    at _x.enterNode (https://typescript-eslint.io/sandbox/index.js:41:23248)
    at yx.enterNode (https://typescript-eslint.io/sandbox/index.js:35:23816)
    at https://typescript-eslint.io/sandbox/index.js:106:3033 2:1 - 2:12

Additional Info

Discovered in JoshuaKGoldberg/eslint-plugin-package-json#117.

@JoshuaKGoldberg JoshuaKGoldberg added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels Jan 20, 2024
@bradzacher
Copy link
Member

Duplicate of #8261

@bradzacher bradzacher marked this as a duplicate of #8261 Jan 20, 2024
@bradzacher bradzacher closed this as not planned Won't fix, can't repro, duplicate, stale Jan 20, 2024
@bradzacher bradzacher added duplicate This issue or pull request already exists and removed accepting prs Go ahead, send a pull request that resolves this issue labels Jan 20, 2024
@JoshuaKGoldberg
Copy link
Member Author

Ha, I did search... whoops.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

2 participants