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-type-assertion] False positive when using generic parameter with default #5487

Closed as not planned
Labels
package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginworking as intendedIssues that are closed as they are working as intended
@srmagura

Description

@srmagura

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=4.7.4&sourceType=module&code=C4TwDgpgBAggxsAlgewHYB4AqA+KBeKAbyjgENgIBzZAJxAC4pMoBfAKA4DMBXVBFVFAC2IAGK84WfFFTchAIwg1sAClL80AZ0bwkaLNgDaAXQCURNlBJbgUUjRqkQMB0+mH1e1JuMcr9x2dXEAA6TVpgFTUAGih5czxcQksra29bUgBJCiFpUkMABl9UtM1beWyIXIJ5Qt8UqwB6RqYAC0RNKAAbRFRoMBpkABNuOAhtBqhmyeaoACYAZgA2OcZMVuguiE5gAFpW0lQhqE1EIehkTjtBe0RgVqEIJDgoZEhHL2FuMriLq9BIFAAOSHEBA6IzFpA2QKJTg4HyRCUXrAIGvGjXKAQGFQAEQEKQyFQGhPbg0G6VIQhMgUah0KC7OKU6nkKi0EB+Eok4BkwRqZk0tn00idUHmRkqCo5Fm09l2UWoECmFIsZXsIA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0ipWkOTJE0fJQ5N0UOdA7RI4MAF8QOoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

typeAction<T>={category:T}functionmyFunc<T=number>(actions:Action<T>[]){constarrayArray=[actions]arrayArray.sort((a,b)=>{constaItem=a[0]constbItem=b[0]// This line produces://// 2362: The left-hand side of an arithmetic operation must be of type 'any',// 'number', 'bigint' or an enum type.//// return aItem.category - bItem.categoryreturn(aItem.categoryasany)-(bItem.categoryasany)})}

ESLint Config

module.exports={"rules":{"@typescript-eslint/no-unnecessary-type-assertion":"error"}}

tsconfig

{"compilerOptions": {"strictNullChecks":true  }}

Expected Result

There should be no linting errors, since theas any type assertions are necessary.

Actual Result

Theas any type assertions are reported as unnecessary.

Additional Info

No response

Versions

packageversion
@typescript-eslint/eslint-plugin5.33.1
@typescript-eslint/parser5.33.1
TypeScript4.7.4
ESLint8.15.0
nodeweb

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginworking as intendedIssues that are closed as they are working as intended

    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