Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to set the tsconfig target to es6 if you don't care about old browsers?

In an Angular application, is it safe to set the tsconfig.json compilerOptions.target to "es6" (or the equivalent "es2015") if you don't care about old browsers?

About this matter, in the official Angular documentation is written:

By default, the target is es5, you can configure the target to es6 if you only want to deploy the application to es6 compatible browser. But if you configure the target to es6 in some old browser such as IE, Syntax Error will be thrown.

So assuming that I do want to deploy my application only to es6 compatible browsers ONLY, should I just set the compile target to es6

Are there any other concerns I should be aware of?

For example, some Angular third-part libraries start not working and throw the notorious error:

TypeError: Class constructors cannot be invoked without 'new'

is it correct to assume that in these cases there is a bug in such third-part library?

like image 387
Francesco Borzi Avatar asked Nov 16 '18 13:11

Francesco Borzi


1 Answers

Yes, Definitely you can use es6 in your tsconfig.json Currently I am using esnext for my application from past 10 months as I am targeting only google chrome, I didn't find any issues arising because of that

Thanks! Happy Coding

like image 116
yaswanthkoneri Avatar answered Nov 14 '22 00:11

yaswanthkoneri