Jump to content

TypeScript 3.1 is now available


nir

Recommended Posts

The latest version of Microsoft’s programming language TypeScript is now available. TypeScript is a language that adds static type-checking to JavaScript.

 

TypeScript 3.1 adds mappable tuples, which is one of the most common patterns in programming, according to Microsoft. This functionality will now be better equipped to express functions such as Promise.all, the team noted.

 

It also adds easier properties on function declarations. Because functions are just objects in JavaScript, properties can be tacked on them easily, the team explained. TypeScript’s traditional approach to this was using namespaces, which support the concept of value-merging, allowing developers to add properties to classes and functions in a declarative way. This was elegant in its time, but hasn’t aged well as ECMAScript modules have become the preferred format for organizing new code, according to the team. As a result, the team wanted to make TypeScripts “smarter” about those sort of patterns and in this latest version, any function declaration or const declaration initialized with a function will be analyzed in terms of its containing scope to track any added properties.

 

Another improvement is that it adds version redirects via typesVersions. TypeScript and JavaScript users often use bleeding-edge features of the language, which can sometimes cause problems for library maintainers when they are forced to choose between supporting new TypeScript features and not breaking older versions of the language, the team explained. When using Node module resolution, TypeScript will now first look at a new field called typesVersions, which will check whether the current version of TypeScript is running or not, and redirect paths accordingly.

 

TypeScript 3.1 also adds new refactoring that can be used to convert functions that return results with chains of .then() and .catch() calls to async functions that use await.

 

Breaking changes to be aware of include removal of vendor-specific declarations and differences in narrowing functions.

 

Source

Link to comment
Share on other sites


  • Views 520
  • Created
  • Last Reply

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...