[@babel/types] - spreadOperator from an array seems to have a bug with 7.8.7
See original GitHub issueBug Report
Current Behavior
A clear and concise description of the behavior.
When I try to build (with react-scripts 3.4.0), I got this error :
Error: C:\Users\thib3113\app\myFile.js: Expected type "Expression" with option {}, but instead got "SpreadElement". at Array.map (<anonymous>)
Input Code
- REPL or Repo link if applicable:
let communeFound = CommuneService.cachedResults.get(insee) || null;
if (!communeFound) {
// spread operator copy the array
communeFound = [...(await this.search({ insee }, 1))].pop();
}
this.search return a promise, the promise return an array.
if I replace by
communeFound = (await this.search({ insee }, 1)).slice(0).pop();
it’s work
Expected behavior/code A clear and concise description of what you expected to happen (or code). with 7.8.6 it works .
- Babel version(s): 7.8.7
- Node/npm version: Node 13.8.0/npm 6.14.2
- OS: win 10 1909
- Monorepo: no
- How you are using Babel: react-scripts (loader I think)
Is that normal ? or a regression ?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (6 by maintainers)
Top Results From Across the Web
@babel/types: Versions | Openbase
Full version history for @babel/types including change logs.
Read more >Package Diff: tap @ 14.10.6 .. 14.10.7
+ UnexpectedSpreadType: "Spread operator cannot appear in class or interface definitions", ... void {\n // ImportExpressions do not have an arguments array.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The problem is that
regeneratordoesn’t support array spread. All your targets support array spread (so the transform isn’t included), but Chrome 49 doesn’t support generators.The change in your targets is probably caused by a
caniuseupdate, used bybrowserslistto decide what browsers it should target.By default,
create-react-appuses>0.2%ad a query to decide which browsers it should target.You can add this to your
package.jsonto force it to include a browser that doesn’t support array spread, so that it gets compiled:(This is still a bug, I will fix it in
regenerator).Fixes by https://github.com/facebook/regenerator/pull/385