Closed as not planned
Closed as not planned
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
type Action<T> = { category: T }
function myFunc<T = number>(actions: Action<T>[]) {
const arrayArray = [actions]
arrayArray.sort((a, b) => {
const aItem = a[0]
const bItem = b[0]
// This line produces:
//
// 2362: The left-hand side of an arithmetic operation must be of type 'any',
// 'number', 'bigint' or an enum type.
//
// return aItem.category - bItem.category
return (aItem.category as any) - (bItem.category as any)
})
}
ESLint Config
module.exports = {
"rules": {
"@typescript-eslint/no-unnecessary-type-assertion": "error"
}
}
tsconfig
Expected Result
There should be no linting errors, since the as any
type assertions are necessary.
Actual Result
The as any
type assertions are reported as unnecessary.
Additional Info
No response
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
5.33.1 |
@typescript-eslint/parser |
5.33.1 |
TypeScript |
4.7.4 |
ESLint |
8.15.0 |
node |
web |