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

False positive(?) with no-unsafe-any #2981

Closed
ethanresnick opened this issue Jul 2, 2017 · 1 comment · Fixed by #3008
Closed

False positive(?) with no-unsafe-any #2981

ethanresnick opened this issue Jul 2, 2017 · 1 comment · Fixed by #3008

Comments

@ethanresnick
Copy link
Contributor

Bug Report

  • TSLint version: 5.4.3
  • TypeScript version: 2.3.4
  • Running TSLint via: (pick one) CLI

TypeScript code being linted

// code snippet
function doesTruthinessCheck(it: any): string {
  if(it) {
    return "john";
  }
  return "jane";
}

with tslint.json configuration:

"no-unsafe-any": true,

Actual behavior

Unsafe use of expression of type 'any'.

Expected behavior

I'd expect no error, as just checking the truthiness of an any typed variable doesn't seem unsafe.

@ajafff
Copy link
Contributor

ajafff commented Jul 6, 2017

I agree that this is a bug. Checking for truthyness or falsyness should be allowed.
#3008 fixes this

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