Test ES2015 transform of accessors w/captured this

This commit is contained in:
Nathan Shively-Sanders
2017-04-24 14:48:25 -07:00
parent 42600fa73f
commit 00848fc46f
4 changed files with 53 additions and 0 deletions
@@ -0,0 +1,15 @@
//// [emitThisInObjectLiteralGetter.ts]
const example = {
get foo() {
return item => this.bar(item);
}
};
//// [emitThisInObjectLiteralGetter.js]
var example = {
get foo() {
var _this = this;
return function (item) { return _this.bar(item); };
}
};
@@ -0,0 +1,13 @@
=== tests/cases/compiler/emitThisInObjectLiteralGetter.ts ===
const example = {
>example : Symbol(example, Decl(emitThisInObjectLiteralGetter.ts, 0, 5))
get foo() {
>foo : Symbol(foo, Decl(emitThisInObjectLiteralGetter.ts, 0, 17))
return item => this.bar(item);
>item : Symbol(item, Decl(emitThisInObjectLiteralGetter.ts, 2, 14))
>item : Symbol(item, Decl(emitThisInObjectLiteralGetter.ts, 2, 14))
}
};
@@ -0,0 +1,19 @@
=== tests/cases/compiler/emitThisInObjectLiteralGetter.ts ===
const example = {
>example : { readonly foo: (item: any) => any; }
>{ get foo() { return item => this.bar(item); }} : { readonly foo: (item: any) => any; }
get foo() {
>foo : (item: any) => any
return item => this.bar(item);
>item => this.bar(item) : (item: any) => any
>item : any
>this.bar(item) : any
>this.bar : any
>this : any
>bar : any
>item : any
}
};
@@ -0,0 +1,6 @@
// @target: es5
const example = {
get foo() {
return item => this.bar(item);
}
};