BT

InfoQ Homepage News Microsoft Releases TypeScript 2.4

Microsoft Releases TypeScript 2.4

Bookmarks

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

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.