- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScript
Description
latest nightly build as of October 6, 2016:
interface A { kind: 'A'; a: number; }
interface B { kind: 'B'; b: number; }
type AB = A | B;
export function toResult<Z extends { kind: K; }, K extends string>(
    value: AB | Z,
    orElse: (value: Z) => number
): number {
    switch (value.kind) {
        case 'A': return value.a; // <-- problem, value isn't narrowed to A
        case 'B': return value.b;
        default: return orElse(value);
    }
}Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScript