Skip to content

Strange type narrowing with Discriminated union types #9254

Closed
@Lenne231

Description

@Lenne231

TypeScript Version:

nightly (1.9.0-dev.20160619-1.0)

image

Expected behavior:

Type of shape should be never or Shape so that we can still access type to throw an Error.

  throw new Error('Unknown type. Type: ' + shape.type);

Actual behavior:

Type of shape is { type: 'rectangle'; width: number; height: number }.

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