Add additional tests

This commit is contained in:
Anders Hejlsberg
2016-08-01 07:04:43 -07:00
parent ade89a6032
commit b3b4c34b60

View File

@@ -1,3 +1,5 @@
// @strictNullChecks: true
// Repro from #9977
type IDLMemberTypes = OperationMemberType | ConstantMemberType;
@@ -12,7 +14,7 @@ interface InterfaceType {
interface OperationMemberType {
type: "operation";
idlType: IDLTypeDescription | null;
idlType: IDLTypeDescription;
}
interface ConstantMemberType {
@@ -47,4 +49,39 @@ function foo(memberType: IDLMemberTypes) {
else if (memberType.type === "operation") {
memberType.idlType.origin; // string
}
}
// Repro for issue similar to #8383
interface A {
kind: true;
prop: { a: string; };
}
interface B {
kind: false;
prop: { b: string; }
}
function f1(x: A | B) {
while (true) {
x.prop;
if (x.kind === true) {
x.prop.a;
}
if (x.kind === false) {
x.prop.b;
}
}
}
function f2(x: A | B) {
while (true) {
if (x.kind) {
x.prop.a;
}
if (!x.kind) {
x.prop.b;
}
}
}