TypeScript 2.4 Adds Dynamic Import Expressions
TypeScript 2.4 Adds Dynamic Import Expressions
Written by Ian Elliot   
Tuesday, 04 July 2017

There's a new version of TypeScript with support for dynamic import expressions, string enums, and weak type detection. 

TypeScript was developed by Microsoft ,and is a superset of JavaScript that builds on the ECMAScript standard and includes support for static types. Your TypeScript code then gets transformed into clean, runnable JavaScript.


TypeScript 2.4's main improvement is the support for dynamic import expressions. These are ECMAScript’s new import calls, which import a module and return a promise to that module. The example given is that of a webpage that allows you to create and edit images, where you want to download multiple images in a zip file. If you chose to load the functionality to download multiple files lazily,  import() expressions let you load a module on the fly as a Promise. In other words, you can send less JavaScript over the wire for more common scenarios, so achieving faster page load times for critical content, but still providing the more unusual options.

Safer callback parameter checking is another area of improvement. This means that when internal data is handed off through callbacks – specifically, Promises,

When checking whether two functions are assignable to one another, TypeScript checks whether their parameters are bidirectionally assignable. We call this function parameter bivariance. There are a number of reasons for this, but it mainly stems from TypeScript’s structural nature and how we’ve tried to match people’s intuition.

Our experience has been that users generally don’t run into issues with this all that much; however, we did start to see that this model broke down on containers which handed internal data off through callbacks – specifically, Promises, TypeScript compares the parameters that are callbacks, and identifies problems where code is attempting to assign incompatible parameters.

Checking for weak types has also been added.  Any type that contains only optional properties is considered a weak type since it provides few restrictions on what can be assigned to it. In TypeScript 2.4, it’s now an error to assign anything to a weak type when there’s no overlap in properties. The developers say that you can think of this as TypeScript “toughening up” the weak guarantees of these types to catch what would otherwise be silent bugs.

The final major improvement is support for string enums. Enums have been provided since early versions of TypeScript to mark sets of related numeric values. This latest release has added string enums, so your enum members can contain string initializers.

More Informationtypescriptlogo

TypeScript On GitHub

What's New In TypeScript 2.4

Related Articles

TypeScript 2.3 Released

TypeScript 2.2 Adds More Code Actions

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, FacebookGoogle+ or Linkedin.



Europe Code Week 2017 Now Underway

This year's Europe Code Week lasts from October 7th to 22nd and, with spin-offs taking place in African and Latin America, is expected to reach millions of participants who will try out some codi [ ... ]

Visual Studio Gets Quantum Language

Microsoft has announced it is releasing a new programming language and computing simulator designed specifically for quantum computing, and the language will be included in Visual Studio.

More News




blog comments powered by Disqus

Last Updated ( Saturday, 19 August 2017 )

RSS feed of news items only
I Programmer News
Copyright © 2017 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.