TypeScript 2.0 Beta Announced

Microsoft has released TypeScript 2.0 Beta. You can now download TypeScript 2.0 Beta for Visual Studio 2015.

Microsoft has released TypeScript 2.0 Beta. To experience it, one can now download TypeScript 2.0 Beta for Visual Studio 2015, but it requires VS 2015 Update 3. This release comes with several new features, such as new workflow so as to get the .d.ts files. Given below are a few more features which will give you an idea of everything new with TypeScript 2.0 Beta.
Non-nullable Types
As per Microsoft, the null and undefined are among the two ‘most common sources of bugs in JavaScript.’ Earlier ‘TypeScript 2.0, null and undefined were in the domain of every type.’ This means that if you had a function which took a string, you would not be able to know for sure about the type alone, whether you actually had a string or if you might actually have a null.
Microsoft states,
“In TypeScript 2.0, the new --strictNullChecks flag changes that. string just means string and number means number.”
In one of the statements of Microsoft, it was stated that
“What if you wanted to make something nullable? Well we’ve brought two new types to the scene: null and undefined. As you might expect, null can only contain null, and undefined only contains undefined. They’re not totally useful on their own, but you can use them in a union type to describe whether something could be null/undefined.”
Postfix operator is introduced by Microsoft. It has an ability to take null and undefined out of the type of any expression.
Control Flow Analysis for Types
Microsoft stated that,
“TypeScript’s support for handling nullable types is possible thanks to changes in how types are tracked throughout the program.”
As far as TypeScript 2.0 is concerned, the company has started the use of control flow analysis so as to understand better what a type has to be at a particular location.
Easier Module Declarations
One of the official statements of the company says,
“Sometimes you want to just tell TypeScript that a module exists, and you might not care what its shape is.” However, it was quite a hassle and hence, the company removed the boilerplate.
When you are ready to outline the shape of the module, you can easily come back to the declarations and refine the structure as per your requirements.
If you are one of those who depends on a package with numerous modules, then writing them out can be quite a tedious task; however with TypeScript 2.0 you can now easily put wildcards in these declarations.
You can now import any path with starts with foo/ and TypeScript will go on to assume that it exists. You can also take advantage of this, if your module loader can understand the way of importing based on certain pattern.
Microsoft made a statement that says,
“Now whenever you import a path ending with !text, TypeScript will understand that the import should be typed as a string.”