Using TypeScript 2.2, I attempted to compile my ES6 module (js file) with the tsc compiler and it successfully converted it into valid ES5 code. Previously, I relied on tools like Google's Tracur for this task. I was unsure if this capability of compiling ES6 files to ES5 was present in the tsc compiler. Has this feature been included in the latest TypeScript versions?
After inspecting the changes in tsc, I couldn't find any mention of this feature being added. Does anyone have information on when this functionality was introduced?
Below is an example from my test.js file:
function Add(...numberArr){
let result = 0;
numberArr.forEach((n) => result += n);
return result;
}
The compiled version using tsc is as follows:
"use strict";
function Add() {
var numberArr = [];
for (var _i = 0; _i < arguments.length; _i++) {
numberArr[_i] = arguments[_i];
}
var result = 0;
numberArr.forEach(function (n) { return result += n; });
return result;
}
Note: To utilize this feature, the AllowJS flag must be set to true in the tsconfig.json file.