Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correctly transform spreads to use proper concat method
- Loading branch information
Showing
7 changed files
with
44 additions
and
5 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
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
9 changes: 9 additions & 0 deletions
9
packages/babel-plugin-transform-spread/test/fixtures/regression/issue-8907/exec.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,9 @@ | ||
const arr = []; | ||
|
||
arr.concat = () => { | ||
throw new Error('Should not be called'); | ||
}; | ||
|
||
expect(() => { | ||
const x = [...arr]; | ||
}).not.toThrow(); |
7 changes: 7 additions & 0 deletions
7
packages/babel-plugin-transform-spread/test/fixtures/regression/issue-8907/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,7 @@ | ||
const arr = []; | ||
|
||
arr.concat = () => { | ||
throw new Error('Should not be called'); | ||
}; | ||
|
||
const x = [...arr]; |
7 changes: 7 additions & 0 deletions
7
packages/babel-plugin-transform-spread/test/fixtures/regression/issue-8907/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,7 @@ | ||
const arr = []; | ||
|
||
arr.concat = () => { | ||
throw new Error('Should not be called'); | ||
}; | ||
|
||
const x = [].concat(arr); |
2 changes: 1 addition & 1 deletion
2
packages/babel-plugin-transform-spread/test/fixtures/spread/array-literal-first/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 |
---|---|---|
@@ -1 +1 @@ | ||
var lyrics = babelHelpers.toConsumableArray(parts).concat(["head", "and", "toes"]); | ||
var lyrics = [].concat(babelHelpers.toConsumableArray(parts), ["head", "and", "toes"]); |
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 |
---|---|---|
|
@@ -3,5 +3,5 @@ function foo() { | |
bar[_key] = arguments[_key]; | ||
} | ||
|
||
return bar.concat(); | ||
return [].concat(bar); | ||
} |