TypeScript, Microsoft’s free and open source Java superset programming language which works on any browser, any host, or any OS, has long been available since Mid 2012. Today, though, the company has announced that TypeScript 2.0 beta is now being rolled out.
Overall, the TypeScript 2.0 beta adds in plenty of new features, such as a new workflow for getting
.d.ts files. Highlights of TypeScript 2.0, (as noted by Microsoft,) include the following:
- Non Nullable Types:
undefinedwere in the domain of every type. That meant that if you had a function that took a
string, you couldn’t be sure from the type alone of whether you actually had a
string– you might actually have
null. In TypeScript 2.0, the new
--strictNullChecksflag changes that.
- Control Flow Analysis for Types: TypeScript’s support for handling nullable types is possible thanks to changes in how types are tracked throughout the program. In 2.0, we’ve started using control flow analysis to better understand what a type has to be at a given location. For instance, consider this function.
- Easier Module Declarations: Sometimes you want to just tell TypeScript that a module exists, and you might not care what its shape is. We made it easier and got rid of the boilerplate. When you’re ready to finally outline the shape of a module, you can come back to these declarations and define the structure you need. What if you you depend on a package with lots of modules? Writing those out for each module might be a pain, but TypeScript 2.0 makes that easy too by allowing wildcards in these declarations!
So, there you have it! Those are most of the new features seen in TypeScript 2.0. If you’re eager to try out TypeScript 2.0, you can download TypeScript 2.0 Beta for Visual Studio 2015, or run, “npm install -g [email protected]” to download.
With greeting of Winbeta.org