'I am using TS 2.2 and I tried compiling my ES6 module ( js file) using tsc and it did compile into valid ES5 code. I was using google's Tracur OR some other tool int he past to do so. I believe, this feature, of compiling js files from ES6 to ES5, was not part of tsc compiler. Has this been added in the new TS versions?? I tried looking into the changes in tsc but did not find this feature been added. Does anyone knows, when this feature has been added ??
Following is my test.js file,
function Add(...numberArr){
let result = 0;
numberArr.forEach((n) => result += n);
return result;
}
compiled file with tsc looks below,
"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: We need to set the AllowJS flag to true in the tsconfig.json file to take advantage of this feature though.
typescript always had an embedded transpiler, you probably haven't noticed.