|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.
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.
or email your comment to: firstname.lastname@example.org
|Last Updated ( Tuesday, 31 July 2018 )|