We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cb47351 commit 077bd1aCopy full SHA for 077bd1a
tests/cases/compiler/discriminantPropertyCheck.ts
@@ -66,4 +66,36 @@ function foo6(x: Item) {
66
if (x.foo !== undefined && x.qux) {
67
x.foo.length; // Error, intervening discriminant guard
68
}
69
-}
+}
70
+
71
+// Repro from #27493
72
73
+enum Types { Str = 1, Num = 2 }
74
75
+type Instance = StrType | NumType;
76
77
+interface StrType {
78
+ type: Types.Str;
79
+ value: string;
80
+ length: number;
81
82
83
+interface NumType {
84
+ type: Types.Num;
85
+ value: number;
86
87
88
+function func2(inst: Instance) {
89
+ while (true) {
90
+ switch (inst.type) {
91
+ case Types.Str: {
92
+ inst.value.length;
93
+ break;
94
+ }
95
+ case Types.Num: {
96
+ inst.value.toExponential;
97
98
99
100
101
0 commit comments