Skip to content

type checking after instainceOf condition in else block is working incorrectly #5523

Closed
@stepancar

Description

@stepancar

see example in playground

interface IFoo {
    value: string[]|string;
}

function bar(options: IFoo) {
    var val = options.value;
    var result: string;
    if (val instanceof Array) {
        result = val.join('')
    } else {
        result = val;
    }
}

val has one of two types strting[] or string
in 'if' condition checked instanceofArray
in else statement compiler should know that val has string type

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