Skip to content
This repository was archived by the owner on Mar 25, 2021. It is now read-only.
This repository was archived by the owner on Mar 25, 2021. It is now read-only.

Rule no-unnecessary-type-assertion doesn't work if tsconfig has "strict": true #4840

Description

@guidsdo

Bug Report

Rule no-unnecessary-type-assertion doesn't work if your tsconfig.json has "strict": true. It was made so that it only works if you have "strictNullChecks": true but should also work for "strict": true since that covers all strict rules.

Bug introduction: b836f28#diff-2237d1e758ab18614b7d976b89e56ea0R53
Strict rule explanation: https://www.typescriptlang.org/docs/handbook/compiler-options.html

Note, will fix this myself so PR incoming.

Reproduction using TSLint Playground

Playground doesn't allow you to change the tsconfig?

TypeScript code being linted

tsconfig.json

{
  "compilerOptions": {
    /* Enable all strict type-checking options. */
    "strict": true,
    /* Enable strict null checks. */
    // "strictNullChecks": true
  }
}

Code

const x = "y";
x!.length;

with tslint.json configuration:

{
  "defaultSeverity": "error",
  "rules": {
    "no-unnecessary-type-assertion": true
  }
}

Actual behavior

No errors.

Expected behavior

An error!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions