Anders Hejlsberg returned to Microsoft's Build conference in 2016 to talk about the current state of TypeScript and show off some amazing features coming in the next few months.
Hejlsberg divided his talk into three main parts, allocating the first 15 minutes to retelling of the high-level story of TypeScript. "TypeScript: JavaScript that scales" is how he described the language and its goal of closing the "JavaScript feature gap". The demos involved basic type checking, statement completion, and how the compiler output compares to the source.
After the brief introduction, he showed off what's changed since Build 2015. The team has a 3 to 4 month cadence that has resulted in 4 main releases in the past year.
In an Angular 2 demo, Hejlsberg showed how to embed the TypeScript compiler in the browser, eliminating the separate step of recompiling code after a file change.
He took the same demo application and repeated it using React, showing off TypeScript's ability to understand JSX, the embedded markup technology favored by React developers. To drive the point home, he refactored the name of a component and showed how TypeScript updated all of the component references throughout the project, including inside the embedded JSX code. Included in the demo was the integration with webpack and the community driven TypeScript loader.
What we're moving towards with our tools -- Visual Studio and Visual Studio Code -- is actually using the TypeScript infrastructure as our language service for JavaScript. Visual Studio Code has already switched to using that.
This language service is called Salsa and Visual Studio Code switched to it in version 0.10.10.
The modified TypeScript compiler can use any jsdoc information provided by the developer. In addition, if there are any TypeScript definition files in a project, Salsa can use them to provide statement completion for plain old JavaScript. TypeScript not required.
In the final 15 minutes, the future of TypeScript took center stage. For TypeScript 2.0, the current road map consists of:
- Non-nullable types
- Control flow based typed analysis
- Async/await downlevel support
- Readonly properties
- Declared 'this' type in functions
- Improved typings acquisition
Version 2.0 is expected to be completed in a "couple of months".
Regarding the upcoming non-nullable types, a new compiler flag called strictNullChecks
will be available that eliminates the ability for a type to be undefined
or null
. A number
can only be a number, never undefined or null.
After demoing the new non-nullable types and control flow based type analysis on his sample code, Hejlsberg was able to declare: "This code has no bugs."
A powerful demo at the end of the presentation showed off the strength of the new TypeScript type checks and how it can easily deal with the sometimes confusing ways of JavaScript. "JavaScript has some quirks, but you can teach a compiler about the quirks and you can have it check all of these things", he said, adding, "This is nuts!"
For more detail on where TypeScript is going, Watch the entire Channel 9 video, "What's New in TypeScript".