Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Throw error when compiling
super()
in arrow functions with def…
…ault / rest parameters (#15163) * Fix: Throw when super in arrow with default / rest * Add allowInsertArrowWithRest and improve throw * Update packages/babel-traverse/src/path/conversion.ts Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com> Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
- Loading branch information
1 parent
871fd5e
commit e7405b9
Showing
10 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
.../babel-plugin-transform-arrow-functions/test/fixtures/arrow-functions/super-call/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,6 @@ | ||
class Bar extends Foo { | ||
constructor() { | ||
let f = () => super(); | ||
f(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...el-plugin-transform-arrow-functions/test/fixtures/arrow-functions/super-call/options.json
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,4 @@ | ||
{ | ||
"plugins": ["transform-arrow-functions"], | ||
"throws": "When using '@babel/plugin-transform-arrow-functions', it's not possible to compile `super()` in an arrow function without compiling classes.\nPlease add '@babel/plugin-transform-classes' to your Babel configuration." | ||
} |
6 changes: 6 additions & 0 deletions
6
.../babel-plugin-transform-arrow-functions/test/fixtures/arrow-functions/super-prop/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,6 @@ | ||
class Bar extends Foo { | ||
constructor() { | ||
let f = () => super.x; | ||
f(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...el-plugin-transform-arrow-functions/test/fixtures/arrow-functions/super-prop/options.json
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,4 @@ | ||
{ | ||
"plugins": ["transform-arrow-functions"], | ||
"throws": "When using '@babel/plugin-transform-arrow-functions', it's not possible to compile `super.prop` in an arrow function without compiling classes.\nPlease add '@babel/plugin-transform-classes' to your Babel configuration." | ||
} |
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
6 changes: 6 additions & 0 deletions
6
...nsform-parameters/test/fixtures/parameters/arrow-default-super-no-classes-plugin/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,6 @@ | ||
class Bar extends Foo { | ||
constructor() { | ||
let f = (x = super()) => x; | ||
f(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...rm-parameters/test/fixtures/parameters/arrow-default-super-no-classes-plugin/options.json
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,4 @@ | ||
{ | ||
"plugins": ["transform-parameters"], | ||
"throws": "When using '@babel/plugin-transform-parameters', it's not possible to compile `super()` in an arrow function with default or rest parameters without compiling classes.\nPlease add '@babel/plugin-transform-classes' to your Babel configuration." | ||
} |
6 changes: 6 additions & 0 deletions
6
...transform-parameters/test/fixtures/parameters/arrow-rest-super-no-classes-plugin/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,6 @@ | ||
class Bar extends Foo { | ||
constructor() { | ||
let f = (...args) => super(...args); | ||
f(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...sform-parameters/test/fixtures/parameters/arrow-rest-super-no-classes-plugin/options.json
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,4 @@ | ||
{ | ||
"plugins": ["transform-parameters"], | ||
"throws": "When using '@babel/plugin-transform-parameters', it's not possible to compile `super()` in an arrow function with default or rest parameters without compiling classes.\nPlease add '@babel/plugin-transform-classes' to your Babel configuration." | ||
} |
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