-
-
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 workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
Related PR: #4795 (review)
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have read the FAQ and my problem is not listed.
Repro
{
"rules": {
"@typescript-eslint/restrict-plus-operands": ["error"]
}
}
const a = 'string' as string & { foo: 'bar' }
const b = 42 as number & { foo: 'bar' };
const c = 42n as bigint & { foo: 'bar' };
console.log(a + 'string')
console.log(b + 42);
console.log(c + 42n);
Expected Result
No linting error on lines 6 and 7, as the rule restrict-plus-operands
doesn't error when there is a valid string intersection but errors with valid number and bigint intersections.
Actual Result
Error on line 6: Operands of '+' operation must either be both strings or both numbers.ESLint(@typescript-eslint/restrict-plus-operands)
Error on line 7: Operands of '+' operation must be both bigints.ESLint(@typescript-eslint/restrict-plus-operands)
Additional Info
Real-world use case: vuejs/eslint-plugin-vue#1839 (comment)
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
5.18.0 |
@typescript-eslint/parser |
5.18.0 |
TypeScript |
4.6.2 |
ESLint |
8.7.0 |
node |
N/A |
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 workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin