Skip to content

Ternary operator result not type checked correctly #19213

Closed
@OliverJAsh

Description

@OliverJAsh

TypeScript Version: 2.6.0rc, also 2.5.2

Code

{
    // expected error, got error
    const x1: { blur?: string } = { blur: 1 };

    // expected error, but got none!
    const x2: { blur?: string } = 'foo' ? { blur: 1 } : {};

    // expected error, got error
    const x3: { blur?: string } = (() => {
        if ('foo') {
            return { blur: 1 };
        } else {
            return {};
        }
    })();
}

Related to #14758?

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