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
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I haveread the FAQ and my problem is not listed.
Repro
{"rules": {"@typescript-eslint/restrict-plus-operands":"error" }}declareconsta:{}&string;declareconstb:string;constx=a+b;// Operands of '+' operation must either be both strings or both numbers. Consider using a template literal. (@typescript-eslint/restrict-plus-operands)
Expected Result
No error
Actual Result
Operands of '+' operation must either be both strings or both numbers. Consider using a template literal. (@typescript-eslint/restrict-plus-operands)Additional Info
The minimal example above might seem nonsense, using{} & string, but it's to be minimal. I encountered a situation in real code involving complex type inferences in which one of the operands apparently ended up being inferred asstring | (Buffer & string) (which also seems nonsense, maybe I should open an issue at TS too... Regardless,WhateverType & string is a string, so the linter shouldn't complain).
Versions
| package | version (attempt 1, withXO) | version (attempt 2, minimal, withoutXO) |
|---|---|---|
@typescript-eslint/eslint-plugin | 3.10.1 | 4.0.1 |
@typescript-eslint/parser | 3.10.1 | 4.0.1 |
TypeScript | 4.0.2 | 4.0.2 |
ESLint | 7.7.0 | 7.8.1 |
node | 12.14.1 | 12.14.1 |