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

strict-boolean-expression false negative #2757

Closed
OliverJAsh opened this issue May 13, 2017 · 1 comment
Closed

strict-boolean-expression false negative #2757

OliverJAsh opened this issue May 13, 2017 · 1 comment

Comments

@OliverJAsh
Copy link
Contributor

Bug Report

  • TSLint version: 5.2.0
  • TypeScript version: 2.3.2
  • Running TSLint via: (pick one) CLI

TypeScript code being linted

// fp-ts is the npm module, version 0.2.7
import { array } from 'fp-ts';

const hasTweetsAfterRangeEnd = (tweets: {}[]) => (
    array.last(tweets)
        .map(() => true)
        .getOrElse(() => false)
);

export const isLastPage = () => (tweets: {}[]) => {
    return !hasTweetsAfterRangeEnd(tweets);
};

with tslint.json configuration:

{
    "rules": {
        "no-unused-variable": true,
        "strict-boolean-expressions": true
    }
}

and tsconfig.json:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es6",
        "strictNullChecks": true
    },
    "files": [
        "./src/publication.ts"
    ]
}

Actual behavior

 tslint --project tsconfig.json --type-check ./src/publication.ts

ERROR: src/publication.ts[10, 13]: This type is not allowed in the operand for the '!' operator because it is always truthy. Only booleans are allowed.

Expected behavior

No errors.

Notes

If I remove no-unused-variable, the error disappears.

@OliverJAsh
Copy link
Contributor Author

Also, if I make the return type of hasTweetsAfterRangeEnd explicit as boolean, the error disappears.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants