Update tests

This commit is contained in:
Anders Hejlsberg 2017-02-16 17:42:22 -08:00
parent 2ca6164fea
commit e512376b0c
5 changed files with 7 additions and 17 deletions

View File

@ -1,10 +0,0 @@
// @noImplicitThis: true
let o = {
d: this, // error, this: any
m() {
return this.d.length; // error, this: any
},
f: function() {
return this.d.length; // error, this: any
}
}

View File

@ -9,7 +9,7 @@ export interface Foo {
export const obj = {
m(): this is Foo {
let dis = this as Foo;
let dis = this as {} as Foo;
return dis.a != null && dis.b != null && dis.c != null;
}
}

View File

@ -9,7 +9,7 @@ interface Foo {
export const obj = {
m(): this is Foo {
let dis = this as Foo;
let dis = this as {} as Foo;
return dis.a != null && dis.b != null && dis.c != null;
}
}

View File

@ -2,9 +2,10 @@ class MyClass {
t: number;
fn() {
type ContainingThis = this;
//type of 'this' in an object literal is the containing scope's this
var t = { x: this, y: this.t };
var t: { x: MyClass; y: number };
var t: { x: ContainingThis; y: number };
}
}

View File

@ -32,15 +32,14 @@ extend1({
});
extend2({
init() {
this // this: any because the contextual signature of init doesn't specify this' type
this // this: containing object literal type
this.mine
this.willDestroy
//this.willDestroy
},
mine: 13,
foo() {
this // this: any because of the string indexer
this // this: containing object literal type
this.mine
this.willDestroy
}
});