Skip to content

TypeScript Compiler does not understand resulting types when using && #12174

Closed
@Ristaaf

Description

@Ristaaf

TypeScript Version: 2.0.8

Code

// A *self-contained* demonstration of the problem follows...
let s:string=("" && false);

Expected behavior:
Since ("" && false) is "" in JavaScript I should be able to assign the resulting value to a string, but TypeScript thinks that this will become a boolean.
Actual behavior:
Compiler error claiming that a boolean cannot be assigned to a string

Disclaimer: I think that the behaviour of the && operator in JavaScript is horrible, however it is what it is and TypeScript should honour it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions