-
-
Notifications
You must be signed in to change notification settings - Fork 485
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(transformer/arrow-functions):
_this = this
should be inserted a…
…fter super call expression (#8024) related: #7792 This PR doesn't contain fixing the async arrow function in `super()`, which is difficult for our architecture. I just found that `esbuild`'s implementation is quite simpler! https://esbuild.github.io/try/#dAAwLjI0LjAALS10YXJnZXQ9ZXMyMDE2AGNsYXNzIEMgZXh0ZW5kcyBTIHsKICBjb25zdHJ1Y3RvcigpIHsKICAgIHN1cGVyKGFzeW5jICgpID0+IHRoaXMpOwogICAgYXN5bmMoKSA9PiB7fQogIH0KfQ
- Loading branch information
Showing
14 changed files
with
290 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
...s/babel-plugin-transform-class-properties/test/fixtures/private-loose/foobar/options.json
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
...ides/babel-plugin-transform-class-properties/test/fixtures/private-loose/foobar/output.js
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
...des/babel-plugin-transform-class-properties/test/fixtures/private-loose/foobar/reason.txt
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...es/babel-plugin-transform-class-properties/test/fixtures/public-loose/foobar/options.json
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
...rides/babel-plugin-transform-class-properties/test/fixtures/public-loose/foobar/output.js
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
...ides/babel-plugin-transform-class-properties/test/fixtures/public-loose/foobar/reason.txt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...-plugin-transform-async-to-generator/test/fixtures/class/this-after-super-nested/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class Outer { | ||
constructor() { | ||
async () => { return [this, 1]; }; | ||
|
||
class Inner extends Outer { | ||
constructor() { | ||
if (condition) { | ||
const _super = super(); | ||
this.fn = async () => { return [this, 2]; }; | ||
} | ||
|
||
super(); | ||
async () => { return [this, 3]; }; | ||
} | ||
} | ||
} | ||
} | ||
|
||
class Outer2 { | ||
constructor() { | ||
async () => [this, 4]; | ||
|
||
class Inner extends Outer2 { | ||
constructor() { | ||
if (condition) { | ||
const _super = super(); | ||
this.fn = async () => [this, 5]; | ||
} | ||
|
||
super(); | ||
async () => [this, 6]; | ||
} | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...plugin-transform-async-to-generator/test/fixtures/class/this-after-super-nested/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
class Outer { | ||
constructor() { | ||
var _this = this; | ||
babelHelpers.asyncToGenerator(function* () { | ||
return [_this, 1]; | ||
}); | ||
|
||
class Inner extends Outer { | ||
constructor() { | ||
var _this2; | ||
|
||
if (condition) { | ||
const _super = (super(), _this2 = this); | ||
this.fn = babelHelpers.asyncToGenerator(function* () { | ||
return [_this2, 2]; | ||
}); | ||
} | ||
|
||
super(); | ||
_this2 = this; | ||
babelHelpers.asyncToGenerator(function* () { | ||
return [_this2, 3]; | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
|
||
class Outer2 { | ||
constructor() { | ||
var _this3 = this; | ||
babelHelpers.asyncToGenerator(function* () { | ||
return [_this3, 4]; | ||
}); | ||
|
||
class Inner extends Outer2 { | ||
constructor() { | ||
var _this4; | ||
|
||
if (condition) { | ||
const _super = (super(), _this4 = this); | ||
this.fn = babelHelpers.asyncToGenerator(function* () { | ||
return [_this4, 5]; | ||
}); | ||
} | ||
|
||
super(); | ||
_this4 = this; | ||
babelHelpers.asyncToGenerator(function* () { | ||
return [_this4, 6]; | ||
}); | ||
} | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...sync-to-generator/test/fixtures/class/this-after-super-with-async-arrow-function/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class S {} | ||
|
||
class C extends S { | ||
constructor() { | ||
super(async () => { | ||
this; | ||
}); | ||
} | ||
} | ||
|
||
class C2 extends S { | ||
constructor() { | ||
super(async () => this); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...ync-to-generator/test/fixtures/class/this-after-super-with-async-arrow-function/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class S {} | ||
|
||
class C extends S { | ||
constructor() { | ||
var _this; | ||
super(babelHelpers.asyncToGenerator(function* () { | ||
_this; | ||
})); | ||
_this = this; | ||
} | ||
} | ||
|
||
class C2 extends S { | ||
constructor() { | ||
var _this2; | ||
super(babelHelpers.asyncToGenerator(function* () { | ||
return _this2; | ||
})); | ||
_this2 = this; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...s/babel-plugin-transform-async-to-generator/test/fixtures/class/this-after-super/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class S {} | ||
|
||
class C extends S { | ||
constructor() { | ||
if (true) { | ||
const _super = super(); | ||
this.fn = async () => { return [this, 1]; }; | ||
} | ||
|
||
super(); | ||
async () => { return [this, 2]; }; | ||
} | ||
} | ||
|
||
class C2 extends S { | ||
constructor() { | ||
if (true) { | ||
const _super = super(); | ||
this.fn = async () => [this, 1]; | ||
} | ||
|
||
super(); | ||
async () => [this, 2]; | ||
} | ||
} |
Oops, something went wrong.