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-unsafe-assignment] Misleading error message for object destructuring #11387

Open
Labels
accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinggood first issueGood for newcomerspackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@szhsin

Description

@szhsin

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=MYewdgzgLgBAZiEMC8MA8AVANAPgBQAmAhlEQFwwYCUKOMeA3jMaVjAJYQCiAtgA5QAnhQCELIjAC%2BVANwAoUJFhNxUlPER4AUgGUA8gDkAdHyIAnCAFM8AcgaSbVWUA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tieQEMAZolp9kySgHMmAW0Qt0kRNGgdokcGAC%2BITUA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

constfoo=<T,>(data:T)=>({ data,isEmpty:!data});const{ data}=foo(JSON.parse('{}'));

ESLint Config

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

tsconfig

{"compilerOptions": {// ...  }}

Expected Result

If the linter wants to report an unsafe destructuring ofany type, the message should clearly indicate it’s due to destructuring from an object, not an array or tuple.

Actual Result

The code produces the following error:

Unsafe array destructuring of a tuple element with an `any` value

data is inferred asany, which makes sense and it's fair for the rule to report that.

What doesn't make sense is the error message — it's an object destructuring, not an array. The message is confusing and makes it sound like a tuple or array is involved, when it's clearly just pulling a property off an object.

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinggood first issueGood for newcomerspackage: 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