(edited to fix the mistaken reference to Java)
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 typescript@beta” to download.