Search code examples
javascripttypescriptinternet-explorer-9

Is Typecscript 100% compatible with IE9 - if not will it advise what it can't do while you code?


Does Typescript always transpile code (ES6->ES5) into something suitable for IE9. If yes can you provide evidence as I can’t find anything that categorically says all valid ES6 code will be transpiled to work in IE9. (Various sources suggest it can, but not clear if that a general thing or full on yes it just works)

If not, does it warn or give errors to say that you can’t use feature X. For example I see from the Babel site (https://babeljs.io/docs/learn-es2015/ ) that it can’t transpile or polyfil Proxies, so I’m guessing if it can’t change a Proxy into valid pre-ES6 code then Typescript will have the same issue?

Again if I look at https://kangax.github.io/compat-table/es6/ and say open up “Destructuring, declarations” then it shows Babel with 21/22 and TS with only 15/22. Does this mean that TS can’t work with as much as Babel? If I use TS, will it warn me if I try to use such syntax.


Solution

  • The JavaScript code generated by the TypeScript compiler doesn't need a runtime library. This is a design choice.

    In the ES6 improvement, two things:

    1. New ES6 syntax;
    2. New ES6 API.

    New ES6 syntax like class, arrow functions, const, let, for of are well converted to ES3, the generated code will run on IE8.

    TypeScript doesn't provide any API. Some ES6 API can be polyfilled: Promise, Array.from, etc. So, we can use TypeScript with es6-shim, for example.

    Some API, like Proxy, can not be polyfilled at all.

    does it warn or give errors to say that you can’t use feature X

    Yes, but compared to ES3 or ES5 instead of IE8 or IE9.

    You still have to know your target browsers.