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

[no-unnecessary-type-assertion] false positive when asserting via non-null assertion operator #529

Closed
Labels
bugSomething isn't workinghas prthere is a PR raised to close thispackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@vkrol

Description

@vkrol

Repro
https://github.com/vkrol/typescript-eslint-no-unnecessary-type-assertion-undefined

module.exports={parser:"@typescript-eslint/parser",parserOptions:{project:"tsconfig.json",},plugins:["@typescript-eslint"],rules:{"@typescript-eslint/no-unnecessary-type-assertion":"error",}};
declarefunctionfoo(str?:string):void;declareconststr:string|null;foo(str!);

Expected Result
No errors.
Actual Result
Error:

D:\Projects\typescript-eslint-no-unnecessary-type-assertion-undefined\index.ts  4:5  error  This assertion is unnecessary since the receiver accepts the original type of the expression  @typescript-eslint/no-unnecessary-type-assertion✖ 1 problem (1 error, 0 warnings)  1 error and 0 warnings potentially fixable with the `--fix` option.

Additional Info
The change that introduced this regression:#478.

Versions

packageversion
@typescript-eslint/eslint-plugin1.9.0
@typescript-eslint/parser1.9.0
TypeScript3.4.5
ESLint5.16.0
node10.15.3
npm6.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghas prthere is a PR raised to close thispackage: 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