Skip to content

Unexpected error: This condition will always return 'false' since the types 'boolean' and 'number' have no overlap.(2367) #35925

Closed
@mhevery

Description

@mhevery

TypeScript Version: 3.7.2

Search Terms:

Code

if (true == 1) console.log('This will always execute because of type coercion, TypeScript error is wrong.');
if (true === 1) console.log('This will never execute because error is correct.');

Expected behavior:
if(true == 1) should not produce an error as it is true in JS.

Actual behavior:
if(true == 1) produce this error This condition will always return 'false' since the types 'boolean' and 'number' have no overlap.(2367)

Playground Link:
Playground

Related Issues:
#35567

Metadata

Metadata

Assignees

No one assigned

    Labels

    Won't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions