SHARE:

What’s new in TypeScript 2.6 ?

 

Version 2.6 of Microsoft’s TypeScript language has been changed to Release Candidate. This new version comes with more rigor in the audit to help developers better detect errors. The language introduces a strict check flag that is introduced by –strictFunctionTypes. The TypeScript language program manager explains that in strict verification any function that does not come from a method has its parameters compared “contravariantly”.

Typically, TypeScript compared the parameters in a “bivariant” way, which brings benefits such as a simpler model for working with arrays. TypeScript 2.6 has found a compromise by increasing the rigor on all types of functions except methods while allowing modeling of use cases such as event handlers and simplified table management.

Microsoft’s JavaScript language, which was five years old on Oct. 1, has gained momentum, so much so that it has been used in the recent rewriting of the Angular JavaScript framework. Version 2.5 of TypeScript was released at the end of August. Another new feature introduced by TypeScript 2.6 is error-killing comments using // @ ts-ignore comments. Microsoft avoided the removal of errors in TypeScript, because in most cases where users requested that they be removed, errors could be resolved by more precise configuration files, or by using an “any” assertion, said Rosenwasser.

He adds that “however, over time, we have seen two motivating examples of migration from JavaScript to TypeScript overcoming type checks that reside in legacy code.” When migrating JavaScript to TypeScript, removing errors can be very useful for developers because they often run into a model that is difficult to model. Rather than spend a lot of time trying to understand the model, developers can now postpone this work and concentrate on their actual work, thanks to the deletion comments that make it possible to ignore errors that do not hinder not the proper functioning of the code.

To override type checks in existing code, some large organizations update project dependencies in tandem. As a result, any code changes that introduce a type verification error will require a fix to avoid breaking the code generation job. According to Rosenwasser, “Even though error detection is useful, the reality is often that the code continues to work and that development teams have limited resources. Microsoft recommends that you use the delete comments sparingly and always provide an explanation to help understanding.

With TypeScript 2.6, model strings tagged in a module are now cached after the initial call. This new feature of TypeScript puts it as close to the latest revisions to the ECMAScript specification that underlies JavaScript. The standalone TypeScript compiler now provides localized messages via NPM when using the –locale flag. The mode –watch, for the emission of modules, has been accelerated.

Support improvements are planned for tools such as Visual Studio and Visual Studo Code with this release. Version 2.6 of the language allows developers to refactor comments in the JSDoc documentation into TypeScript annotations. Organizational changes have been made to the DOM declarations in lib.d.ts. TypeScript 2.6 can be installed via NPM by running the command npm install -g typecript @ rc or via NuGet. It can also be installed via Visual Studio 2017.

Written by

anthonygiretti

Anthony is a specialist in Web technologies (14 years of experience), in particular Microsoft .NET and learns the Cloud Azure platform. He has received twice the Microsoft MVP award and he is also certified Microsoft MCSD and Azure Fundamentals.