Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug: [no-unnecessary-condition] doesn't report on unnecessary optional array index access whennoUncheckedIndexedAccess is enabled #10960

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@ronami

Description

@ronami

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 havesearched for related issues and found none that matched my issue.
  • I haveread the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=5.8.2&fileType=.tsx&code=CYUwxgNghgTiAEYD2A7AzgF3hkmBc8AgjDFAJ4A8A3vFAPwGYwCWKA5vAL4B8A3AFD8A9EPgAlEAAckMHMHgAjMvAAqZSSADKYFpKxQ02ABYIkCgFbgszQ9LRpmCiMoDkAVxSgAZqxDAX-DiYANoADAC6AHRQAvzMXvAAFEEYYeF00QCU8FT88PAi8ADyesyoUBCIRlCsrBw2KC5YKOC4aLDKJnB52LipEdG8%2Bfn8nILxSSlpGVDZufmFmkZIbhDyCghw0rJ%2Bim5YwEi4jRh0PVMRMwJjQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0yHJgBNK%2BSpPRRE0aB2iRwYAL4gtQA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3QAacDUhFYAVSLQ%2Bg9ABMAkkVXoAHmoCC0aOhLCwo9FIC%2BIK0A&tokens=false

Repro Code

declareconsttest:Array<{a?:string}>;// Reported by TypeScript as the object is possibly 'undefined'test[0].a;if(test[0]?.a){// Optional chaining isn't necessary heretest[0].a;}if(test[0]?.a){// Should be reported but doesn't?test[0]?.a;}

ESLint Config

module.exports={parser:"@typescript-eslint/parser",rules:{"@typescript-eslint/no-unnecessary-condition":"error",},};

tsconfig

{"compilerOptions": {"strictNullChecks":true,"noUncheckedIndexedAccess":true  }}

Expected Result

I expected the rule to report on unnecessary optional array index access whennoUncheckedIndexedAccess is enabled.

Actual Result

The rule seems to fails to catch these unnecessary optional array index access cases whennoUncheckedIndexedAccess is enabled.

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp