Skip to content
This repository has been 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

Closed
guidsdo opened this issue Aug 26, 2019 · 1 comment · Fixed by #4841
Closed

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

guidsdo opened this issue Aug 26, 2019 · 1 comment · Fixed by #4841

Comments

@guidsdo
Copy link
Contributor

guidsdo commented Aug 26, 2019

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!

JoshuaKGoldberg pushed a commit that referenced this issue Aug 31, 2019
…nnecessary-type-assertion` (#4841)

* Fix bug where the strict ts flag wasn't recognised correctly

This commit fixes #4840

* Make sure to only test 'strict' flag option for tsc 2.4+

* Review: put getCompilerOptions into var
@JoshuaKGoldberg
Copy link
Contributor

🤖 Beep boop! 👉 TSLint is deprecated 👈 and you should switch to typescript-eslint! 🤖

🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋

@palantir palantir locked and limited conversation to collaborators Sep 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants