Closed
Description
- 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/no-explicit-any": 2
}
}
function getNumber<K extends keyof any, T extends { [P in K]: number }>(key: K, obj: T): number {
return obj[key];
}
Currently, the expression keyof any
is probably the only (sane) way of saying "a type of things that can be object keys". But it is disallowed under no-explicit-any
.
The long way of string | number | symbol
isn't portable enough because of the symbol
part.
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
4.18.0 |
@typescript-eslint/parser |
4.18.0 |
TypeScript |
4.2.3 |
ESLint |
7.22.0 |
node |
14.15.4 |