TypeScript 1.6 Beta Is Announced With React/JSX Support

2014-04-30-TypeScriptLanguageMicrosoft just announced the beta version of TypeScript 1.6, an object based scripting language developed by Microsoft.

TypeScript originally developed and maintained by Microsoft is a typed superset of JavaScript that let you write object-oriented code that compiles to plain JavaScript. TypeScript is open source and supports all browsers and operating systems.

Jonathan Turner wrote in his blog post :

Today, we’re making a beta of the upcoming TypeScript 1.6 available. There are a bunch of new features coming in the 1.6 release, and we wanted to give you a preview of these features and time to give us feedback.

React/JSX support

One of the key philosophies of TypeScript is to let you write TypeScript anywhere you can develop using JavaScript. While we’ve worked with teams such as Dojo, Aurelia, and Angular to ensure using TypeScript is as easy as using JavaScript, there was still an important library that that presented a difficulty for TypeScript developers: React. This was due to the lack of support for JSX, a popular way of writing DOM and native components in JS. React heavily leverages JSX in everyday code. Unfortunately, the syntax for JSX conflicted with the cast syntax that TypeScript already used.

Class expressions

This release also makes it possible to write class expressions, as we continue to round out the ES6 support in TypeScript.  Similar to class declarations, class expressions allow you to create new classes.  Unlike class declarations, you can use class expressions wherever you use an expression.  For example, you can now create a class and use it in your extends clause.

User defined type guards

This allows you to work with not only typeof and instanceof checks, which need a type that JavaScript understands, but now you can work with interfaces and do custom analysis.

Intersection types

Common patterns in JS that haven’t been easy to express in TypeScript are mixins and extending existing classes with new methods.  To help with this, we’re adding a new type operator ‘&’ that will combine two types together.  While it was possible to do this before by creating a new interface that inherited from two other types, this tended to be clunky and couldn’t be used in the case you wanted to use it most: combining generic types.

Abstract classes

A long-standing feature request for TypeScript has been supporting abstract classes.  Similar in some ways to interfaces, abstract classes give you a way of creating a base class, complete with default implementations, that you can build from with the intention of it never being used directly outside of the class hierarchy.

Generic type aliases

Leading up to TypeScript 1.6, type aliases were restricted to being simple aliases that shortened long type names.  Unfortunately, without being able to make these generic, they had limited use.  We now allow type aliases to be generic, giving them full expressive capability.

Potentially-breaking changes

Along with all the new features, we also spent some time tightening and fixing up a few areas of the system to generally work better, help you catch more errors, and be closer to how other tools work.  In this release we now require that an object literal should be matched directly.  We’ve also updated the module resolution logic to work more closely to what you would expect for the type of output module you selected.  You can read the full list of potential breaking changes with their mitigations.

Object literal strictness

We have made object compatibility stricter to help catch a class of common bugs.  You can learn more about this in the 1.6 beta post.

Catching more errors

Starting with 1.6, we’re tightening up some of our object checking rules. In the beta, you’ll see that objects need to match more closely when they are assigned.

Improved module resolution

Previously, TypeScript used a hybrid approach for resolving both CommonJS and RequireJS. Unfortunately, this meant that module resolution didn’t feel at home in either style, and instead made you structure projects in a way that didn’t feel natural for that particular module loader.

Read more details here : What’s new in TypeScript 1.6


One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s