javascript - TSC: what does --target ES3 compatibility flag do? -


i installed typescript npm package:

npm install typescript 

and ran

node_modules\.bin\tsc doodle.ts -t es3 

where doodle.ts has:

var test = document.queryselector('.test'); 

it echoed same in output doodle.js.

how configure in output, get:

var test = document.getelementsbyclassname('.test')[0]; 

shouldn't -t es3 flag take care of such compatibility aspects?

flags -es5, es3, etc indeed take care of supporting transpiling of advanced ts/es6 features equivalent (when possible) in previous versions of javascript (for example, for..off).

however, document.queryselector not part of ecmascript standard. it's part of dom api, , ignored typescript. transpiler not trying provide browser compatibility, rather, language compatibility. might find shims they're specific ecmascript versions roll api shims it, that's misunderstanding they're not same thing.

with typescript, still need use shims missing dom features browser-specific.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -