Skip to content

Commit 00848fc

Browse files
committed
Test ES2015 transform of accessors w/captured this
1 parent 42600fa commit 00848fc

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//// [emitThisInObjectLiteralGetter.ts]
2+
const example = {
3+
get foo() {
4+
return item => this.bar(item);
5+
}
6+
};
7+
8+
9+
//// [emitThisInObjectLiteralGetter.js]
10+
var example = {
11+
get foo() {
12+
var _this = this;
13+
return function (item) { return _this.bar(item); };
14+
}
15+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/compiler/emitThisInObjectLiteralGetter.ts ===
2+
const example = {
3+
>example : Symbol(example, Decl(emitThisInObjectLiteralGetter.ts, 0, 5))
4+
5+
get foo() {
6+
>foo : Symbol(foo, Decl(emitThisInObjectLiteralGetter.ts, 0, 17))
7+
8+
return item => this.bar(item);
9+
>item : Symbol(item, Decl(emitThisInObjectLiteralGetter.ts, 2, 14))
10+
>item : Symbol(item, Decl(emitThisInObjectLiteralGetter.ts, 2, 14))
11+
}
12+
};
13+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/compiler/emitThisInObjectLiteralGetter.ts ===
2+
const example = {
3+
>example : { readonly foo: (item: any) => any; }
4+
>{ get foo() { return item => this.bar(item); }} : { readonly foo: (item: any) => any; }
5+
6+
get foo() {
7+
>foo : (item: any) => any
8+
9+
return item => this.bar(item);
10+
>item => this.bar(item) : (item: any) => any
11+
>item : any
12+
>this.bar(item) : any
13+
>this.bar : any
14+
>this : any
15+
>bar : any
16+
>item : any
17+
}
18+
};
19+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @target: es5
2+
const example = {
3+
get foo() {
4+
return item => this.bar(item);
5+
}
6+
};

0 commit comments

Comments
 (0)