Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ternary operator result not type checked correctly #19213

Closed
OliverJAsh opened this issue Oct 16, 2017 · 3 comments
Closed

Ternary operator result not type checked correctly #19213

OliverJAsh opened this issue Oct 16, 2017 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@OliverJAsh
Copy link
Contributor

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?

@mhegazy
Copy link
Contributor

mhegazy commented Oct 16, 2017

Duplicate of #12745, fixed by #16363

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Oct 16, 2017
@mhegazy mhegazy added this to the TypeScript 2.6.1 milestone Oct 16, 2017
@mhegazy mhegazy closed this as completed Oct 16, 2017
@ahejlsberg
Copy link
Member

@mhegazy I don't think this is fixed as you indicate. The issue here is that we reduce the type of 'foo' ? { blur : 1 } : {} to simply {} which then is assignable to { blur?: string }.

@mhegazy mhegazy added Duplicate An existing issue was already created and removed Fixed A PR has been merged for this issue labels Oct 16, 2017
@mhegazy mhegazy removed this from the TypeScript 2.6.1 milestone Oct 16, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Oct 16, 2017

Sorry about that.. it is not fixed. Marking it as duplicate of #14758

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants