typescripttsc

TypeScript target ES3 doesn't replace or polyfill ES5 methods


Array.prototype.indexOf and Date.now have been introduced in ES5. Why doesn't Typescript transpile, if I compile following code stored in file test.ts?

Date.now();
[1,2,3].indexOf(2);

The command I use is tsc -t es3 test.ts. The resulting test.js is completely identical to test.ts.


Solution

  • Why doesn't Typescript transpile, if I compile following code stored in file test.ts?

    More