Skip to content

Boolean() function is not working with type-guard. #30321

Closed
@rockmandash

Description

@rockmandash

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)
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions