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

strict-comparison false positive (TSLint 5.18.0) #4774

Closed
vladimir-djokic opened this issue Jun 24, 2019 · 2 comments · Fixed by #4786
Closed

strict-comparison false positive (TSLint 5.18.0) #4774

vladimir-djokic opened this issue Jun 24, 2019 · 2 comments · Fixed by #4786

Comments

@vladimir-djokic
Copy link

Bug Report

  • TSLint version: 5.18.0
  • TypeScript version: 3.5.2
  • Running TSLint via: VSCode

TypeScript code being linted

const foo: string | null = null;

if (foo !== null) { // <-- Cannot use '!==' comparator for type 'null'. (strict-comparisons)tslint(1)
    // ...
}

with tslint.json configuration:

{
    "extends": "tslint:all",
    "rules": {
        "linebreak-style": false,
        "no-null-keyword": false,
        "strict-type-predicates": false
    }
}

Actual behavior

strict-comparison error.

Expected behavior

No error.

@vladimir-djokic vladimir-djokic changed the title strict-comparison false negative (TSLint 5.18.0) strict-comparison false positive (TSLint 5.18.0) Jun 24, 2019
@ulrichb
Copy link
Contributor

ulrichb commented Jun 24, 2019

Same here. The exclusion for "if one of the operands is null or undefined" doesn't seem to work.

@ulrichb
Copy link
Contributor

ulrichb commented Jun 24, 2019

... and in addition to the sample above it should also work for non-primitives on the other side, right?

Example:

const someObj : {} | undefined = {};
if (someObj === undefined) { /* ... */ }

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.

3 participants