“Today we are thrilled to announce the availability of TypeScript 4.0! This version of the language represents our next generation of TypeScript releases, as we dive deeper into expressivity, productivity, and scalability.
With TypeScript 4.0, there are no major breaking changes. In fact, if you’re new to the language, now is the best time to start using it. The community is already here and growing, with working code and great new resources to learn. And one thing to keep in mind: despite all the good stuff we’re bringing in 4.0, you really only need to know the basics of TypeScript to be productive!
If you’re already using TypeScript in your project, you can either get it through NuGet or use npm with the following command:
npm install -D typescript
You can also get editor support by
Downloading for Visual Studio 2019/2017
Installing the Insiders Version of Visual Studio Code or following directions to use a newer version of TypeScript
The 4.0 Journey
It’s worth digging a bit into how we got here. In our past two major versions, we looked back at some highlights that shined over the years. For TypeScript 4.0, we’re going to keep up that tradition.
TypeScript 3.1 extended the capabilities of mapped types to work on tuple and array types, and made it dramatically easier to attach properties to functions without resorting to TypeScript-specific runtime features that have fallen out of use.
TypeScript 3.2 allowed object spreads on generic types, and leveraged 3.0’s capabilities to better model meta-programming with functions by strictly typing bind, call, and apply. TypeScript 3.3 focused a bit on stability following 3.2, but also brought quality-of-life improvements when using union type methods, and added file-incremental builds under —build mode.
In the 3.4 release, we leaned farther into supporting functional patterns, with better support for immutable data structures, and improved inference on higher-order generic functions. As a big plus, this release introduced the —incremental flag, a way to get faster compiles and type-checks by avoiding a full rebuild on every run of TypeScript, without project references.
With TypeScript 3.5 and 3.6, we saw some tightening up of the type system rules, along with smarter compatibility checking rules.
Much more recently, 3.8 and 3.9 have brought type-only imports/exports, along with ECMAScript features like private fields, top-level await in modules, and new export * syntaxes. These releases also delivered performance and scalability optimizations.
We haven’t even touched on all the work in our language service, our infrastructure, our website, and other core projects which are incredibly valuable to the TypeScript experience. Beyond the core team’s projects is the incredible community of contributors in the ecosystem, pushing the experience forward, and helping out with DefinitelyTyped and even TypeScript itself. DefinitelyTyped had just 80 pull requests in 2012 when it first started, picking up on the tail end of the year. In 2019, it had over 8300 pull requests, which still astounds us. These contributions are fundamental to the TypeScript experience, so we’re grateful for such a bustling and eager community that’s been improving the ecosystem and pushed us to constantly improve.
All this brings us to 4.0! So, without further ado, let’s dive into what’s new!
- Variadic Tuple Types
- Labeled Tuple Elements
- Class Property Inference from Constructors
- Short-Circuiting Assignment Operators
- unknown on catch Clauses
- Custom JSX Factories
- Speed Improvements in build mode with —noEmitOnError
- —incremental with —noEmit
- Editor Improvements
- Convert to Optional Chaining
- /* @deprecated / Support
- Partial Semantic Mode at Startup
- Smarter Auto-Imports
- Our New Website!
- Breaking Changes”