Skip to content

Regression in discriminated unions unioned with primitive #10257

@RyanCavanaugh

Description

@RyanCavanaugh

From master

interface Foo {
  kind: "foo";
  name: string;
}
interface Bar {
  kind: "bar";
  length: string;
}

let x: string | Foo | Bar = <any>undefined;
if(typeof x === 'string') {

} else {
  switch(x.kind) {
    case 'foo':
      console.log(x.name); // <-- Error, Property 'name' does not exist on type 'Foo | Bar'.
  }
}

Compiles without error in 2.1.0-dev.20160729

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions