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.
Issue Description
const users: Record<string, string> = {};
export const getUser = (name: string) => {
users[name] ??= 'hei';
return users[name]!; // Error: @typescript-eslint/no-unnecessary-type-assertion
};
const groups: Record<string, string> = {};
export const getGroup = (name: string) => {
name = `${name}-grp`;
groups[name] ??= 'hei';
return groups[name]!; // No error!
};
I expected that the return
from both functions should produce the @typescript-eslint/no-unnecessary-type-assertion
error. Only the first does. If I remove noUncheckedIndexedAccess
, I get the expected behavior.
Reproduction Repository Link
https://stackblitz.com/edit/vitejs-vite-imvtqxsz?file=src%2Ffoo.ts
Repro Steps
- Open the StackBlitz
npx eslint .
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
8.35.0 |
@typescript-eslint/parser |
8.35.0 |
@typescript-eslint/scope-manager |
8.35.0 |
@typescript-eslint/typescript-estree |
8.35.0 |
@typescript-eslint/type-utils |
8.35.0 |
@typescript-eslint/utils |
8.35.0 |
TypeScript |
5.8.3 |
ESLint |
9.29.0 |
node |
20.19.1 |