-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed as not planned
Closed as not planned
Copy link
Labels
package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-pluginworking as intendedIssues that are closed as they are working as intendedIssues that are closed as they are working as intended
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
export function isPositive(x: number) {
return x > 0;
}
export type PositiveNumberRecord<T extends string | number | symbol> =
Record<T, number> & { __type: 'positiveNumberRecord' };
export const isPositiveNumberRecord = <T extends string | number | symbol>
(value: Record<T, number> | null | undefined): value is PositiveNumberRecord<T> => {
if (!value) {
return false;
}
const values = Object.values(value) as number[]; // FP is here
return values.every(isPositive);
};
ESLint Config
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json']
},
plugins: ['@typescript-eslint'],
rules: {},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking'
]
};
tsconfig
Expected Result
I don't expect any error since the cast is necessary to change unknown[]
to number[]
.
Actual Result
I'm getting an error:
15:20 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion
✖ 1 problem (1 error, 0 warnings)
1 error and 0 warnings potentially fixable with the `--fix` option.
Additional Info
No response
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
5.40.0 |
@typescript-eslint/parser |
5.40.0 |
TypeScript |
4.8.4 |
ESLint |
8.25.0 |
node |
16.16.0 |
Metadata
Metadata
Assignees
Labels
package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-pluginworking as intendedIssues that are closed as they are working as intendedIssues that are closed as they are working as intended