Skip to content

[no-unnecessary-type-assertion] This rule is different from the tslint rule 'no-unnecessary-type-assertion' #1310

@ooyyloo

Description

@ooyyloo

The tslint rule 'no-unnecessary-type-assertion' reports an error only when the type assertions does not change the type of a variable. But this rule seems to report errors when the types of source variable and the receiver are different. These two rules are different, but the ROADMAP.md tells me these two rules are the same.

Example

  let x: string | undefined;
  let y: string | undefined = x!;

Consider about the code above. There is no error when using tslint rule 'no-unnecessary-type-assertion', but there are errors when using '@typescript-eslint/no-unnecessary-type-assertion'.

Versions

package version
@typescript-eslint/eslint-plugin 2.10.0
@typescript-eslint/parser 2.10.0
TypeScript 3.7.2
ESLint 6.7.2
node 12.13.0
npm 6.12.0

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