Skip to content

Commit 0a90a4b

Browse files
committed
Accept new baselines
1 parent b3b4c34 commit 0a90a4b

File tree

3 files changed

+336
-73
lines changed

3 files changed

+336
-73
lines changed

tests/baselines/reference/narrowingByDiscriminantInLoop.js

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//// [narrowingByDiscriminantInLoop.ts]
2+
23
// Repro from #9977
34

45
type IDLMemberTypes = OperationMemberType | ConstantMemberType;
@@ -13,7 +14,7 @@ interface InterfaceType {
1314

1415
interface OperationMemberType {
1516
type: "operation";
16-
idlType: IDLTypeDescription | null;
17+
idlType: IDLTypeDescription;
1718
}
1819

1920
interface ConstantMemberType {
@@ -48,6 +49,41 @@ function foo(memberType: IDLMemberTypes) {
4849
else if (memberType.type === "operation") {
4950
memberType.idlType.origin; // string
5051
}
52+
}
53+
54+
// Repro for issue similar to #8383
55+
56+
interface A {
57+
kind: true;
58+
prop: { a: string; };
59+
}
60+
61+
interface B {
62+
kind: false;
63+
prop: { b: string; }
64+
}
65+
66+
function f1(x: A | B) {
67+
while (true) {
68+
x.prop;
69+
if (x.kind === true) {
70+
x.prop.a;
71+
}
72+
if (x.kind === false) {
73+
x.prop.b;
74+
}
75+
}
76+
}
77+
78+
function f2(x: A | B) {
79+
while (true) {
80+
if (x.kind) {
81+
x.prop.a;
82+
}
83+
if (!x.kind) {
84+
x.prop.b;
85+
}
86+
}
5187
}
5288

5389
//// [narrowingByDiscriminantInLoop.js]
@@ -80,3 +116,24 @@ function foo(memberType) {
80116
memberType.idlType.origin; // string
81117
}
82118
}
119+
function f1(x) {
120+
while (true) {
121+
x.prop;
122+
if (x.kind === true) {
123+
x.prop.a;
124+
}
125+
if (x.kind === false) {
126+
x.prop.b;
127+
}
128+
}
129+
}
130+
function f2(x) {
131+
while (true) {
132+
if (x.kind) {
133+
x.prop.a;
134+
}
135+
if (!x.kind) {
136+
x.prop.b;
137+
}
138+
}
139+
}

0 commit comments

Comments
 (0)