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

 

typescriptlogo 

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

 

Banner


IBM Updates Granite Models
28/10/2024

IBM has released new Granite models that it says provide state-of-the-art performance relative to model size. The Granite 3.0 collection includes a new, instruction-tuned, dense decoder-only LLM.



Sequin - Open Source Message Stream Built On Postgres
31/10/2024

Sequin is a tool for capturing changes and streaming data out of your Postgres database, guaranteeing exactly once processing. What does that mean?


More News

 

espbook

 

Comments




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