Typescript: Boolean() function is not working with type-guard.

Created on 11 Mar 2019  路  1Comment  路  Source: microsoft/TypeScript

When I call Boolean() function to test a union type, it doesn't have type-guard working.
Here is a simple code and VSCode screenshot.

image

function test(number: number | undefined) {
  if (Boolean(number)) {
    console.log(number)
  }
}
Duplicate

Most helpful comment

Duplicate of #16655, and there is an open PR fixing this here: #29955

>All comments

Duplicate of #16655, and there is an open PR fixing this here: #29955

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blendsdk picture blendsdk  路  3Comments

dlaberge picture dlaberge  路  3Comments

DanielRosenwasser picture DanielRosenwasser  路  3Comments

weswigham picture weswigham  路  3Comments

uber5001 picture uber5001  路  3Comments