BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Microsoft Releases TypeScript 2.4

Microsoft Releases TypeScript 2.4

Microsoft has released TypeScript 2.4, the latest version of their JavaScript superset language. The release doesn't have a lot of new features, but keeps the language fresh and adds some abilities that have dogged developers.

The biggest feature Microsoft is showcasing this time around is support for dynamic import() expressions. This feature is in stage 3 of the TC39 process (expected for ECMAScript 2018) and allows developers to "conditionally and lazily import other modules and libraries to make your application more efficient and resource-conscious". Previously, if a module wanted to import a library, it had to be done at the top of the file. One caveat is that it won't work when targeting es2015 modules. To use this feature with Webpack 2+ code-splitting (for example), developers must target esnext modules.

In tightening up some of the type checking, some breaking changes have resulted. For example, the improved weak type detection means that if your code tries to assign properties to a weak type without matching at least one property, it will now fail in 2.4.

Looking over the reaction from the community, developers gave thanks for the inclusion of string Enums. Many showed off the different "hacks" they came up with in order to use strings-based Enums. One of the most popular methods was to use a union type:

type Sports = "Football" | "Baseball";

With the new string-initialized enums, the above example can be expressed more naturally:

​enum Sports {
    Football = "FOOTBALL",
    Baseball = "BASEBALL"
}

Visual Studio 2017 users can get the latest installer while other editors such as Visual Studio Code will get the update soon. Developers can read more about the release in a blog post from Microsoft.

Rate this Article

Adoption
Style

BT