1
votes

For performance purposes, compatibility, and scalability, which is the best ECMAScript target for the compiler TypeScript to use in a module with NodeJS?

According to NodeJS ES6 (ECMAScript 2015) is not fully supported. Is it worth to use ES6 or is it better for the compatibility to add the target ES5 with the associated workarounds generated automatically by Typescript?

On other hand, at this moment these are the in-progress functions in NodeJS for ES6:

  --harmony-do-expressions (enable "harmony do-expressions" (in progress))
  --harmony-class-fields (enable "harmony fields in class literals" (in progress))
  --harmony-static-fields (enable "harmony static fields in class literals" (in progress))
  --harmony-array-flatten (enable "harmony Array.prototype.flat{ten,Map}" (in progress))
  --harmony-locale (enable "Intl.Locale" (in progress))

I don't know if I need these features at this moment but for the maintainability of the code maybe it is not the best option.

1
Since you can increase performance by sacrificing compatibility, this is very much a matter of opinion.Quentin
It wasn't an answer, it was pointed out that you were asking for something which is "primarily opinion-based" and thus off-topic.Quentin

1 Answers

1
votes

Node.js fully supports ECMAScript 2015, with the exception of tail call optimization and ES modules (experimental support is available with a flag and .mjs extension).

It doesn't make sense to transpile to ES5 with TypeScript in Node, TypeScript doesn't follow the specs strictly and can also have its limitations, notably the extension of native ES6 classes.