Skip to content

Ternary results consider both branches even when boolean literal values make one impossible #14206

Closed
@krryan

Description

@krryan

TypeScript Version: 2.3.0-dev.20170217

Code

const aOrB = true ? 'a' : 'B';
const a: 'a' = aOrB;

Expected behavior:
Compiles without error.

Actual behavior:

Type '"a" | "B"' is not assignable to type '"a"'.
Type '"B"' is not assignable to type '"a"'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in codeWorking as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions