Add tests

This commit is contained in:
Anders Hejlsberg
2017-03-07 09:07:53 -08:00
parent fa02c808d1
commit 0ac92b4706
@@ -1,7 +1,5 @@
// @declaration: true
// @strictNullChecks: true
// @noImplicitAny: true
// @noImplicitThis: true
// @strict: true
// @target: es5
// In methods of an object literal with no contextual type, 'this' has the type
@@ -51,6 +49,42 @@ let p1: Point = {
}
};
let p2: Point | null = {
x: 10,
y: 20,
moveBy(dx, dy, dz) {
this.x += dx;
this.y += dy;
if (this.z && dz) {
this.z += dz;
}
}
};
let p3: Point | undefined = {
x: 10,
y: 20,
moveBy(dx, dy, dz) {
this.x += dx;
this.y += dy;
if (this.z && dz) {
this.z += dz;
}
}
};
let p4: Point | null | undefined = {
x: 10,
y: 20,
moveBy(dx, dy, dz) {
this.x += dx;
this.y += dy;
if (this.z && dz) {
this.z += dz;
}
}
};
declare function f1(p: Point): void;
f1({
@@ -65,6 +99,20 @@ f1({
}
});
declare function f2(p: Point | null | undefined): void;
f2({
x: 10,
y: 20,
moveBy(dx, dy, dz) {
this.x += dx;
this.y += dy;
if (this.z && dz) {
this.z += dz;
}
}
});
// In methods of an object literal with a contextual type that includes some
// ThisType<T>, 'this' is of type T.