Skip to content

Type guard failures with expressions that can use for type guards #9862

@falsandtru

Description

@falsandtru

TypeScript Version: 2.0.0

Code

class A<T> {
  private _: T;
}
class B<T> {
  private _: T;
}
function f() {
  var o: A<void> | B<void> = new A<void>();
  o instanceof A || o instanceof B;
  o; // A<any>, should be A<void> | B<void>
}

Expected behavior:

A type of o after expr is A<void> | B<void>.

Actual behavior:

A type of o after expr is A<any>.

Metadata

Metadata

Assignees

Labels

Working as IntendedThe behavior described is the intended behavior; this is not a bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions