-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please 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-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 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
Repro Code
// Warns about invalid operands
let fnNumber = (a: number, b: string) => a + b;
// Doesn't warn
let fnBigint = (a: bigint, b: string) => a + b;
ESLint Config
{
"rules": {
"@typescript-eslint/restrict-plus-operands": [
"error",
{
"allowNumberAndString": false
}
]
}
}
tsconfig
Expected Result
I expected that the 4th line should report the error "Operands of '+' operations must be a number or string, allowing a string + any of: any
, boolean
, null
, RegExp
, undefined
. Got bigint
+ string
."
The docs for allowNumberAndString
specifically mention supporting bigint
:
Whether to allow bigint/number typed values and string typed values to be added together.
Actual Result
There was no error on the 4th line.
Additional Info
In restrict-plus-operands.ts
, line 221
should compare otherType
to ts.TypeFlags.NumberLike | ts.TypeFlags.BigIntLike
instead of just ts.TypeFlags.NumberLike
.
ronami
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please 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-pluginIssues related to @typescript-eslint/eslint-plugin