Closed
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
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 the no-unnecessary-type-assertion
rule should also check for the return type of a function.
Fail
declare function foo(): number;
const a = foo()!; // no error report
const b = foo() as number; // report error but bad fixed: `const b = foo() ; `
const c = <number>foo(); // good now
Pass
declare function foo(): number;
const a = foo();
const b = foo();
const c = foo();
Additional Info
Im ready to send a PR after the issue is marked with the accepting prs
label as indicated on the PR Checklist. Welcome to provide more test cases.
Metadata
Metadata
Assignees
Labels
Go ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueSomething isn't workingSomething isn't workingIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin