Merely upgrading my
package.json to use
"typescript": "^2.0.3" from
"typescript": "^1.8.10" was painless. TypeScript now supports ES2016 (the previous major release 1.8 supported ES2015). I wanted to move on from writing ES2015 to writing ES2016 using my chosen build process. Fortunately, it's supported. Phew. However, due to some advances in ecmascript feature modularisation within the TypeScript compiler the upgrade path is slightly different. I figured that I'd just be able to update the
<a href="https://www.typescriptlang.org/docs/handbook/compiler-options.html">target</a> in my
"es2015", add in the ES2016 preset for Babel and jobs a good 'un. Not so. There were a few more steps to follow. Here's the recipe:
Well, there's no
"es2016" target for TypeScript. You carry on with a target of
"es2015". What I need is a new entry:
"lib": ["dom", "es2015", "es2016"]. This tells the compiler that we're expecting to be emitting to an environment which supports a browser (
"dom"), and both ES2016 and ES2015. Our "environment" is Babel and it's going to pick up the baton from this point. My complete
tsconfig.json looks like this:
I needed the Babel preset for ES2016; with a quick
<a href="https://www.npmjs.com/package/babel-preset-es2016">npm install --save-dev babel-preset-es2016</a> that was sorted. Now just to kick Webpack into gear...
loaders so they cater for ES2016 as well.
And we're there; it works. How do I know? Well; here's the proof:
Much love to the TypeScript team for an awesome job; I can't wait to get stuck into some of the exciting new features of TypeScript 2.0.