Skip to content

Using intersection with unions #8896

Closed
Closed
@blakeembrey

Description

@blakeembrey

TypeScript Version:

1.8 / 1.9

Code

type Foo = { a: string } | { b: string }

interface Bar {
    c: string
}

type Baz = Foo & Bar

let baz: Baz

if (baz.a) {

}

Expected behavior: baz.a should be accessible, at least in 1.9 with the null checks.

Actual behavior: Property a does not exist on type

Edit: To clarify, I suspected it would have let me use it in the if condition in 1.9 since the introduction of strictNullChecks and flow control sounds like it would allow this functionality to pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions