Nataliya Muriy
Marketing Content Creator - you name it, she'll write it!
Posted on Sep 22nd 2017

Perhaps you are already enjoying all the amazing features TypeScript (TS) adds to JavaScript: you might already be in love with its interfaces, abstract classes, and algebraic data types, among many others. TS 2.4 brings more good news. This version of TS comes loaded with improvements, ranging from dynamic import expressions to weak type detection.


Need to request a module at some point while programming? No problem! That can even be done asynchronously thanks to the dynamic `import` expressions which are now part of TypeScript as well as ECMAScript. In other words, modules and libraries can be imported where they’re needed, or even conditionally. Besides, output bundles can be split automatically based on these  import  expressions, so it might be a great idea to use them with the `esnext` module target. Take a look at this Github link for an example of an `async `function.

String enums and infererencing for generics

The new version of TS also brings improvements on string enums and inference for generics. Now string initializers can be part of the enums, as shown on Github:

enum Colors {
    Red = "RED",
    Green = "GREEN",
    Blue = "BLUE",
As far as inferencing for generics, three more capabilities are now in place: return types as inference targets, type parameter inference from contextual types, and stricter checking for generic functions. See here for more details.

Strict contravariance for callback parameters

One more new feature that has been added to TS 2.4 is strict contravariance for callback parameters. The relating of two callback types became much stricter when developers realized that there were some headaches caused by bivariant checking of  `Promise` s and `Observable` s parameters. This new version of the language will perform a check to find out whether a parameter in question is of a callback nature, and if so, it will be checked contravariantly.

No more weak types

Finally, no more weakness in code is allowed! 😉 Now an error message will come up whenever anything is assigned to a weak type without an existing overlap in properties. “What’s a weak type?”, you might wonder. It’s a new concept that’s now part of this version of TS: any type that has only a set of all-optional properties, like this example taken from Github:

interface Options {
    data?: string,
    timeout?: number,
    maxRetries?: number,

Both the weak type and the strict contravariance modifications could result in compile errors in code that was being successfully compiled in prior versions of TS. However, the TS team hopes that these changes will help you catch even more bugs at compile time – and that’s what we love about TS!

TS 2.4 now supported, TS 2.5 – on the way

If you are about to start your TS adventure, click here to learn more about it, and If you would like to use an IDE that will let you enjoy this amazing development experience, check out Angular IDE, CodeMix or MyEclipse.

Our newest release, 2017 CI 8, has added support for TypeScript 2.4; full support for TypeScript 2.5 coming soon!