google / clasp

🔗 Command Line Apps Script Projects
https://developers.google.com/apps-script/guides/clasp
Apache License 2.0
4.59k stars 428 forks source link

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

Open muddi900 opened 2 years ago

muddi900 commented 2 years ago

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