mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Test ES2015 transform of accessors w/captured this
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user