• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// @strict: true
2// @target: esnext
3
4class A { private x: unknown; y?: string; }
5class B { private x: unknown; y?: string; }
6
7declare let ab: A & B;
8ab.y = 'hello';
9ab = {};
10
11function f1(node: A | B) {
12  if (node instanceof A || node instanceof A) {
13    node;  // A
14  }
15  else {
16    node;  // B
17  }
18  node;  // A | B
19}
20
21// Repro from #37659
22
23abstract class ViewNode { }
24abstract class ViewRefNode extends ViewNode { }
25abstract class ViewRefFileNode extends ViewRefNode { }
26
27class CommitFileNode extends ViewRefFileNode {
28  private _id: any;
29}
30
31class ResultsFileNode extends ViewRefFileNode {
32  private _id: any;
33}
34
35class StashFileNode extends CommitFileNode {
36  private _id2: any;
37}
38
39class StatusFileNode extends ViewNode {
40  private _id: any;
41}
42
43class Foo {
44  private async foo(node: CommitFileNode | ResultsFileNode | StashFileNode) {
45		if (
46			!(node instanceof CommitFileNode) &&
47			!(node instanceof StashFileNode) &&
48			!(node instanceof ResultsFileNode)
49		) {
50			return;
51		}
52
53		await this.bar(node);
54	}
55
56  private async bar(node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {}) {
57    return Promise.resolve(undefined);
58  }
59}
60