clasp icon indicating copy to clipboard operation
clasp copied to clipboard

spread operator(`...`) compiles from typescript into a buggy function that returns an empty array

Open muddi900 opened this issue 3 years ago • 0 comments

Code Sample

const a = [...myIter]

Compiled Function

var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};

Expected Behavior

It should return in an Array.

Actual Behavior

It returns and empty array. []

Steps to Reproduce the Problem

  1. Create typescript file locally.
  2. Create an iterator.
  3. use the spread operator inside an array.

Specifications

  • Node version (node -v): 14.16.0
  • Version (clasp -v): 2.4.1
  • OS (Mac/Linux/Windows): Windows 10

muddi900 avatar Aug 05 '22 13:08 muddi900