TypeScript 3.1 Adds Mappable Tuples
Written by Kay Ewbank   
Thursday, 25 October 2018

TypeScript has been updated to add support for mappable tuple and array types.

TypeScript is a superset of JavaScript that was developed by Microsoft. It builds on the ECMAScript standard and includes support for optional static types that are designed to make it easier to use when creating large client or server-side applications. Once created, your TypeScript code then gets transformed into clean, runnable JavaScript. TypeScript includes editor support for Visual Studio 2015 and 2017, Sublime Text 3 and new for this release, Visual Studio Code.

The main improvement to the new version is support for mappable tuple and array types. TypeScript has a mapped object type that can generate new types out of existing ones, and the new feature means that mapped object types work correctly with tuples and arrays.

Namespaces are the second area to be improved. JavaScript, functions are just objects and can have properties added to them just as with any object. This has historically been managed in TypeScript by using namespaces, but the way JavaScript has evolved means this is no longer very useful and can cause problems bringing in code from non-typed sources. This problem has been dealt with by altering the way the TypeScript type checker works so that if there's a function declaration or const declaration that’s initialized with a function, the type-checker will analyze the containing scope to track any added properties.

Other changes include a better way to handle different versions of TypeScript to prevent problems with using the wrong library; and the addition of a refactoring to convert functions that return promises constructed with chains of .then() and .catch() calls to async functions that use await.

There are some breaking changes to this version. In particular, the way narrowing functions work has been changed so that the typeof foo === "function" type guard may provide different results when intersecting with some union types. More details in the TypeScript wiki.  

typescriptlogo

More Information

TypeScript On NuGet

TypeScript On GitHub

Related Articles

TypeScript 3.0 Adds Project References

TypeScript Adds Unused Span Reporting

TypeScript Adds Conditional Types

TypeScript 2.7 Improves Type Inference

TypeScript 2.5 Adds Optional Catch Binding

TypeScript 2.4 Adds Dynamic Import Expressions  

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, Facebook or Linkedin.

Banner


Remembering Grace Hopper On Her 114th Anniversary
09/12/2024

Today sees the start of Computer Science Education Week and  the 2024 Hour of Code. These educational event are timed to coincide with Grace Hopper's birthday on January 9th, 1906 due to her conc [ ... ]



Swimm Releases Copilot Extension For Documentation
03/12/2024

Swimm, best known for its AI-driven software documentation tools, has announced an extension for GitHub Copilot. The Swimm team says the extension means developers using GitHub Copilot Chat can turn C [ ... ]


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Thursday, 25 October 2018 )