📜 ⬆️ ⬇️

Alpha TypeScript 1.5 Announcement

Today we are announcing an alpha version of TypeScript 1.5, the first preview version of the upcoming TS1.5 release. This version provides an opportunity to get acquainted with many new features that we plan to include in the final release.



Three key new things we add to TypeScript tools: a richer experience with ES6, decorators and a new plug-in for Sublime Text .
')
You can try the alpha version today by installing a new compiler via npm .

Improved experience with ES6


In TypeScript 1.5, we added several new features for ES6. We linked these features with the TypeScript type system to give you additional support in the tools when working with new coding patterns inherent in ES6.

Modules


Module syntax in ES6 is a powerful way to work with modules. You can interact with them by importing the module as a whole or by working with individual imported entities.

import * as Math from "my/math"; import { add, subtract } from "my/math"; 


ES6 also supports a number of options for specifying exportable elements. You can expose such declarations as classes or functions. You can also export “default” to import from the module directly. For example:

 // math.ts export function add(x, y) { return x + y } export function subtract(x, y) { return x – y } export default function multiply(x, y) { return x * y } 

 // myFile.ts import {add, subtract} from "math"; import times from "math"; var result = times(add(2, 3), subtract(5, 3)); 


If you have already used TypeScript, you may notice that this is very similar to your own TypeScript external modules. This is not a coincidence: when we created the syntax of external modules in TS, we worked on the same problems. However, the design of the ES6 expands these possibilities even further, demonstrating a powerful and mature design. We will continue to support external TS modules, but at the same time we encourage developers to start using the more powerful syntax of modules from ES6.

Destructuring


Destructuring is a convenient new feature that appears in TS as part of our support for the ES6 standard. With it, you can split or destroy objects and arrays.

 var [x, y] = [10, 20]; [x, y] = [y, x]; // a simple swap 


You can also use disruption to control function parameters:

 var myClient = {name: "Bob", height: 6}; function greetClient({name, height: howTall}) { console.log("Hello, " + name + ", who is " + howTall + " feet tall."); } greetClient(myClient); 


In the example above, the greetClient function accepts a single object with the name and height properties. Using the 'height: howTall' syntax, we can rename the height property to howTall inside greetClient.

And further...


We also added for-of support for improving iterations, compiling let / const in ES5, support for unicode, mode for issuing ES6-code and implemented improvements in support for calculated properties.

Decorators


We are working with the teams Angular , Ember and Aurelia (from the creators of Durandal) on the proposal for decorators in ES7, the previews of which we added to the alpha version of TypeScript 1.5. Decorators allow you to clearly indicate the features of the code. In the example below, we see how the @memoize decorator can be used to mean that a pair of getter and setter can be memosed :

 class Person { @memoize get name() { return `${this.first} ${this.last}` } set name(val) { let [first, last] = val.split(' '); this.first = first; this.last = last; } } 


Developers will be able to create new decorators and mix them when working with a type system.

Plugin for Sublime Text




Together with the alpha version of TypeScript 1.5, we also release a preview of the plug-in for Sublime Text to work with TypeScript , so that those developers using this editor also have the opportunity to work with TypeScript. This plugin works with both Sublime Text 2 and Sublime Text 3 and gives you the opportunity to experience the benefits of the TypeScript type system. Sublime Text and TypeScript plugin are available for OSX, Linux and Windows.


TypeScript commands available in Sublime Text

The plugin for Sublime Text allows you to easily navigate through the code, refactor, format, and examine the code. For those who have tried the plugin that was shown during the demonstration on ng-conf, the updated plugin will seem noticeably quicker, especially on large files.

We'd love to hear your feedback. If you want to leave a comment, tell us about the problem in the tracker on GitHub . Also, do not hesitate to send us your suggestions through the request for inclusion , in order to make the plug-in for Sublime even better.

What's next


This alpha version shows what will be possible to do on TypeScript 1.5 when it is released - and we really want to know what you think about it. We are actively working on TS1.5 - and you can help us make this release better by trying it and telling us about any problems you encounter.

Source: https://habr.com/ru/post/254867/


All Articles