Open PedroHBrasil opened 2 years ago
I have also encountered this issue
I don't know why clasp can't just compile to ES6. This issue can easily be mitigated
The workaround is to use typescript and add this to the tsconfig.json
:
{
"compilerOptions": {
"lib": ["esnext"],
"experimentalDecorators": true,
"target": "ES2015"
}
}
Expected Behavior
When pushing a project written in TypeScript, it would be expected that a
for...of
loop applied on a map iterator (such as the return ofmap.entries()
andmap.keys()
) would result on an executable loop on google apps script.Also, the piece of code
[...map_object.entries()]
should return an array that contains sub-arrays filled with key-value pairs (like[[key1, value1], [key2, value2], ... , [keyN, valueN]]
).Actual Behavior
When pushing a project,
for...of
loops applied to map iterators have their code replaced to non-executable loops (likefor (var _i = 0, _a = map_object.entries(); _i < _a.length; _i++)
Also, the convertion does not handle the piece of code
[...map_object.entries()]
properly, since it's converted to a piece of code that returns an empty array (__spreadArray([], data_map.entries(), true)
).Steps to Reproduce the Problem
const map_object = new Map();
map_object.set("key1", "value1");
.for...of
loop such asfor (const entry of map_object.entries())
.Logger.log(entry);
.Logger.log([...map_object.entries()]);
.Specifications
node -v
): v16.14.0clasp -v
): 2.4.1