TypeScript 2.4 improves load times, weak type-checking

TypeScript 2.4 improves load times, weak type-checking

Version 2.4 of TypeScript, a popular, typed superset of JavaScript, will offer improved load times with the addition of a dynamic import expressions capability. A release candidate version is now available via NuGet or via NPM, using the command npm install -g typescript@rc.

New TypeScript 2.4 features include dynamic import expressions, an ECMAScript feature that allows for asynchronously loading a module at any arbitrary point in a program. The capability results in faster load times for critical content, with less JavaScript being transmitted in many common scenarios. “Projects that use bundlers like Webpack can operate on these import() calls and split code into smaller bundles that can be lazily loaded,” said Daniel Rosenwasser, Microsoft’s program manager for TypeScript.

Also featured in version 2.4 is a check for weak types, which contain only optional properties and have few restrictions on what can be assigned to them. Microsoft wants to strengthen weak guarantees of these types to catch silent bugs. “In TypeScript 2.4, it’s now an error to assign anything to a weak type when there’s no overlap in properties,” Rosenwasser noted. The new check for weak types will cause code to break, so developers will need to declare properties that exist, add an index signature to a weak type, and use a type assertion.

TypeScript 2.4 also offers safer callback parameter checking. “TypeScript will be strict about checking parameters contravariantly with respect to the current check,” Rosenwasser said. The impetus for this change was that TypeScript would check whether parameters are bidirectionally assignable; although this check generally has not caused any issues, this model did break down on containers that handed internal data from callbacks.

Improved inference for generics changes how generics are inferred. TypeScript currently can, for example, make an inference for the return type of a call, which can improve the experience and also catch errors. Version 2.4 also now allows enum members to contain string initializers. TypeScript has supported both string literal types and enums, but users wanted some enums to do some of what string literals can do; the new string enums are the result of this desire, Rosenwasser said.

IDG Insider

PREVIOUS ARTICLE

«Google makes the best Android apps easier to find with Android Excellence

NEXT ARTICLE

Hands-on: Microsoft's Xbox One X is a tiny console with big 4K gaming potential»

Add Your Comment

Most Recent Comments

Our Case Studies

IDG Connect delivers full creative solutions to meet all your demand generatlon needs. These cover the full scope of options, from customized content and lead delivery through to fully integrated campaigns.

images

Our Marketing Research

Our in-house analyst and editorial team create a range of insights for the global marketing community. These look at IT buying preferences, the latest soclal media trends and other zeitgeist topics.

images

Poll

Should companies have Bitcoins on hand in preparation for a Ransomware attack?