question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[@babel/types] - spreadOperator from an array seems to have a bug with 7.8.7

See original GitHub issue

Bug 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
nicolo-ribaudocommented, Mar 5, 2020

The problem is that regenerator doesn’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 caniuse update, used by browserslist to decide what browsers it should target.

By default, create-react-app uses >0.2% ad a query to decide which browsers it should target.

You can add this to your package.json to force it to include a browser that doesn’t support array spread, so that it gets compiled:

"browserslist": [
  ">0.2%",
  "chrome 45"
]

(This is still a bug, I will fix it in regenerator).

2reactions
nicolo-ribaudocommented, Mar 22, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found