Microsoft has announced that TypeScript 2.1 is now generally available. The availability comes with features that Microsoft is claiming can “drastically reduce the friction of starting new projects, make the type-checker much more powerful, and give you the tools to write much more expressive code.”
npm install -g typescript
As a second option, you can also grab up the TypeScript 2.1 installer for Visual Studio 2015 after installing Update 3. TypeScript 2.1 brings many changes and improvements, including, downlevel async/await and significantly improved inference. According to Microsoft, other new and improved features in TypeScript 2.1 include:
- Async Functions: It bears repeating: downlevel async functions have arrived! That means that you can use async/await and target ES3/ES5 without using any other tools.
- Object Rest & Spread: We’ve been excited to deliver object rest & spread since its original proposal, and today it’s here in TypeScript 2.1. Object rest & spread is a new proposal for ES2017 that makes it much easier to partially copy, merge, and pick apart objects.
- keyof and Lookup Types: Many libraries take advantage of the fact that objects are (for the most part) just a map of strings to values. Given what TypeScript knows about each value’s properties, there’s a set of known strings (or keys) that you can use for lookups.
- Mapped Types
- Partial, Readonly, Record, and Pick
- Easier Imports
Please do let us know what you think by dropping us a comment below! And please, keep in mind that Visual Studio Code will usually just prompt you if your TypeScript install is more up-to-date, but you can also follow instructions to use TypeScript 2.1 now with Visual Studio Code or Microsoft’s Sublime Text Plugin.