'Using the spread operator on Iterable gives `Array [ Array Iterator ]`

We recently moved our react project over to nx, and in the process, something weird is now happening with spread operators. I am doing the following

[...Array(someNumber).keys()]

which should give [0,1,2,...,someNumber-1] however when I log the result I get Array [ Array Iterator ]

I have had the same problems when I try and do [...someMap.entries()].

I suspected it might be a problem with Babel, but have tried using both @babel/plugin-transform-spread and @babel/plugin-proposal-object-rest-spread with no luck. We are using the following presets in our react app

"presets": [
    [
      "@nrwl/react/babel",
      {
        "runtime": "automatic"
      }
    ]
  ]

Also, I don't know if this is related, but now we also get an error when using someString.replace saying Uncaught TypeError: someString.replace is not a function

Does anyone know what is causing this problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source