-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed as not planned
Closed as not planned
Copy link
Labels
bugSomething isn't workingSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.triageWaiting for team members to take a lookWaiting for team members to take a lookworking 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.
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 |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.triageWaiting for team members to take a lookWaiting for team members to take a lookworking as intendedIssues that are closed as they are working as intendedIssues that are closed as they are working as intended