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] does not detect unnecessary non-null-assertion on a call expression #8141

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@lvjiaxuan

Description

@lvjiaxuan

Before You File a Proposal Please Confirm You Have Done The Following...

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Link to the rule's documentation

https://typescript-eslint.io/rules/no-unnecessary-type-assertion

Description

I propose that theno-unnecessary-type-assertion rule should also check for the return type of a function.

Fail

declarefunctionfoo():number;consta=foo()!;// no error reportconstb=foo()asnumber;// report error but bad fixed: `const b = foo() ; `constc=<number>foo();// good now

Pass

declarefunctionfoo():number;consta=foo();constb=foo();constc=foo();

Additional Info

Im ready to send a PR after the issue is marked with theaccepting prs label as indicated on the PR Checklist. Welcome to provide more test cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

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