Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinggood first issueGood for newcomerslocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
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 havesearched for related issues and found none that matched my issue.
- I haveread the FAQ and my problem is not listed.
Playground Link
Repro Code
declareconstfalseyBigInt:0n;if(falseyBigInt){}
ESLint Config
module.exports={"rules":{"@typescript-eslint/no-unnecessary-condition":"warn"}}
tsconfig
{"compilerOptions": {"strictNullChecks":true }}
Expected Result
Unnecessary conditional, value is always falsy.
Actual Result
Unnecessary conditional, value is always truthy.
Additional Info
This is a bug with this line.
(type.isLiteral()&&!!type.value); |
The.value
field returns aPseudoBigInt
object that looks like{ negative?: boolean, base10Value: string }
, rather than abigint
itself (for legacy TS support reasons). So checking for truthiness is incorrect; we need to convert to a real bigint.
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinggood first issueGood for newcomerslocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin