Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Profile photo of Wanda Muriy
Nataliya Muriy
Marketing Content Creator - you name it, she'll write it!

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.

Modules

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:

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:

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, Webclipse or MyEclipse.

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

Related Posts

Slack Is Using TypeScript, and You Should Too! Building a desktop application with multiple threads is a challenge not everyone is up to. No problem for TypeScript, though! All the pieces must fit in perfectly to make sure an application doesn’t crash due to even a tiny mistake. For this reason, folks at Slack (and many others) have put their faith in it. How is this made possible? Felix Rieseb...
Creating Your First Angular 4 App Using Angular ID... Some time ago an article Creating My First Web App with Angular 2 in Eclipse was published. Since then, Angular was upgraded and became Angular 4, and new tooling for it in Webclipse appeared. Let’s see how creating a simple application using Angular 4 and new Angular tooling looks.PrerequisitesAngular IDE or Webclipse or MyEclipse 2017+—Choose any...
Angular 4 — the Butterfly, Not the Cocoon. Metamorphosis doesn’t have to be ugly: forget about Kafka or what a butterfly has to go through before it shows its amazing apparel. Angular 4 has evolved for you and is showing its best colors. “Just how different is it from Angular 2?”, you might wonder. There are some overall and package-specific changes, as well as new features.First of all, it...
Navigating through an Angular Project You might now be familiar with easy cruising through a Webclipse or an Eclipse project after reading our blog or thanks to a personal experience, but what if you are more of an Angular guy or gal? No worries, breezy navigation is also a reality for Angular projects.This video will give you some useful tips on how to navigate both between files, and...

Posted on Sep 22nd 2017