BT

Microsoft Releases TypeScript 2.4

| by David Iffland Follow 4 Followers on Jun 29, 2017. Estimated reading time: 1 minute |

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 Stage
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.

Tell us what you think

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

Email me replies to any of my messages in this thread
Community comments

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

Email me replies to any of my messages in this thread

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

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT