Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript target ES3

Tags:

typescript

tsc

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.

like image 452
rainerhahnekamp Avatar asked Mar 07 '23 08:03

rainerhahnekamp


1 Answers

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

  • TypeScript doesn't polyfill.
  • Use corejs to polyfill

More

  • Lib option : https://basarat.gitbooks.io/typescript/content/docs/types/lib.d.ts.html#polyfill-for-old-javascript-engines
like image 122
basarat Avatar answered Mar 15 '23 15:03

basarat