Our Blogs

TypeScript 2.0 unveiled with Simplified Declaration File Acquisition, Non-nullable Types and Readonly modifiers

October 08, 2016
1300 Views
Microsoft has released TypeScript 2.0 with features such as Simplified Declaration File Acquisition, Non-nullable Types and Readonly modifiers. With TypeScript 2.0, developers will be able to get and make use of declaration files.

Commenting on the release, Daniel Rosenwasser, program manager for TypeScript disclosed that the team was excited by the release. It delivers close ECMAScript spec alignment, wide support for JavaScript libraries and tools, and a language service that powers a first class editing experience in all major editors.

Rosenwasser added that learning how to acquire and manage declaration file dependencies" has been a major pain point for users in the past. The latest release provides the command npm install --save @types/lodash. It installs the scoped package  @types/lodash. It is this package which TypeScript 2.0 automatically references when importing lodash anywhere in the developer's program.

TypeScript 2.0 introduces non-nullable types. Eventhough nullable types are supported, the product team is of the opinion that this didn't provide complete protection against null/undefined issues. The non-nullable types allow developers to explicitly express when null/undefined values are acceptable.

You can easily declare properties in TypeScript 2.0 as read-only. Here, any get-accessor without a set-accessor is now considered read-only.

I can't wait to use some of the new features in our production apps. Typescript is/was my bridge into JavaScript development, because IMHO JavaScript was a broken language for a long time, and I am not sure if I could have ever done as much as I have without its existence: On HackerNews, Ed Rochenski

Meanwhile, Rochenski added that non-nullable types, tagged union types, and easy declaration file acquisition are the man attraction of TypeScript 2.0.
Microsoft has also revealed the roadmap for TypeScript. In the upcoming releases, you will find support for ES8 object property spread and rest including decorators for function expressions/arrow functions. Moreover, the product team is also working to provide support for node register hook.

You can contribute to the TypeScript project by visiting GitHub.