TypeScript 2.2 Adds More Code Actions
TypeScript 2.2 Adds More Code Actions
Written by Kay Ewbank   
Monday, 27 February 2017

There's a new release of TypeScript with more code actions, a new object type, and easier string indexing behavior among its improvements. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.

TypeScript was developed by Microsoft for creating complex applications, and is a built-in programming language for Visual Studio. It builds on the ECMAScript standard and adds type-checking. Your TypeScript code then gets transformed into clean, runnable JavaScript.

Improvements to the new version start with better class support for mixins. This has been achieved by loosening some restrictions on classes, and by adjusting the way intersection types operate. These changs mean you can now express mixin-style classes in ES2015, where a class can extend anything that constructs some object type. This can be used to bridge ES2015 classes with APIs like Ember.Object.extend.

The editor is another area that has been improved, with some more quick fixes (also called code actions),  that can guide you in fixing up errors. This includes

  • Adding missing imports
  • Adding missing properties
  • Adding forgotten this. to variables
  • Removing unused declarations
  • Implementing abstract members

There's a new object type in this version that matches any types except for primitive types. This means you can assign anything to the object type except for string, boolean, number, and symbol.

The string handling behavior has been improved with changes to string index signatures. These are part of a type and tell the type system what the result of an element access should be. The idea is that index signatures are meant to model the way that objects can serve as maps or dictionaries in JavaScript.

In previous versions, you couldn't access a property via the string index very easily, but in this version you access it using code such as x.propName. 

The developers have added a new option for JSX, emit mode. This joins the preserve and react options, and is like a combination of the two, in that it emits to .js files (like --jsx react), but leaves JSX syntax alone (like --jsx preserve). The new mode reflects React Native’s behavior, which expects all input files to be .js files.

The final notable change is the addition of support for .the new.target metaproperty added in ES2015. This lets constructors figure out if a subclass is being constructed.

The developers are now working on TypeScript 2.3, and are planning to deliver

  • default types for generics
  • async iterator support
  • downlevel generator support



More Information

What's New In TypeScript 2.2

Related Articles

TypeScript 2.0 Adds Null, Undefined And Never  

Visual Studio "VS 15" Preview Released

TypeScript 1.8 Hits Beta

TypeScript 1.7 Released

Visual Studio Tools Updated

TypeScript 1.5 Released       

TypeScript Goes Light, Moves To GitHub 

TypeScript Fully Accepted into Visual Studio 


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



Microsoft Closing Outlook REST API

Microsoft has announced details of cessation of support for authentication in Outlook REST API, and decommissioning of the API in favor of Microsoft Graph. This will leave some apps unusable unless mo [ ... ]

Where In The World Is Santa? Google and NORAD Keep Track

Today, Christmas Eve, Santa and his elves set off on their annual epic journey with reindeer to deliver presents to children all over the globe in just 24 hours. If you want to know where Santa i [ ... ]

More News




blog comments powered by Disqus


RSS feed of news items only
I Programmer News
Copyright © 2018 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.