mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Add regression test
This commit is contained in:
parent
cb47351851
commit
077bd1afd1
@ -66,4 +66,36 @@ function foo6(x: Item) {
|
||||
if (x.foo !== undefined && x.qux) {
|
||||
x.foo.length; // Error, intervening discriminant guard
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #27493
|
||||
|
||||
enum Types { Str = 1, Num = 2 }
|
||||
|
||||
type Instance = StrType | NumType;
|
||||
|
||||
interface StrType {
|
||||
type: Types.Str;
|
||||
value: string;
|
||||
length: number;
|
||||
}
|
||||
|
||||
interface NumType {
|
||||
type: Types.Num;
|
||||
value: number;
|
||||
}
|
||||
|
||||
function func2(inst: Instance) {
|
||||
while (true) {
|
||||
switch (inst.type) {
|
||||
case Types.Str: {
|
||||
inst.value.length;
|
||||
break;
|
||||
}
|
||||
case Types.Num: {
|
||||
inst.value.toExponential;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user