📜 ⬆️ ⬇️

Together with Visual Studio 2015 release TypeScript 1.5

As you know, Visual Studio 2015 was released last night. At the same time, Microsoft introduced the final version of TypeScript 1.5, incorporating it into the new Visual Studio. It can also be downloaded separately for previous versions of VS or installed using npm. Under the cut - a short list of what's interesting in the new release.



Partial ES6 syntax support


')
Microsoft wants to make TypeScript backward compatible with ES6, and in each new release systematically adds the syntax of the new standard. Version 1.5 is especially rich in innovations: ES6 syntax for modules , destructuring , ellipsis operator , iteration using for ... of , symbols , computed properties , support for let / const and stringing . Stitch Patterning, Carl!

Module system improvements



In addition to supporting ES6 syntax for modules, a compilation has been added to two new module loading formats: SystemJS and UMD. Together with the already supported CommonJS and AMD, this makes it possible to choose one of the four module loading options for the generated code.

// 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)); 


The development team also renamed internal modules to “namespaces”, so that “typescript module” and “typescript external module” are now the same. They say new developers complained and confused.

Tsconfig.json configuration file



Allows you to specify a list of files to compile and configure the compiler.

 { "compilerOptions": { "module": "commonjs", "noImplicitAny": true, "removeComments": true, "preserveConstEnums": true, "out": "../../built/local/tsc.js", "sourceMap": true }, "files": [ "core.ts", "sys.ts", "types.ts", "scanner.ts" ] } 


ES7 Decorators



The ES7 standard will not stabilize soon, but in TypeScript it is already possible to use the new syntax of decorators, albeit in an experimental mode:

 import {Component, View, NgFor, bootstrap} from "angular2/angular2"; import {loadFile} from "audioFile"; import {displayAudioFile} from "displayAudio"; @Component({selector: 'file-list'}) @View({template: ` <select id="fileSelect" size="5"> <option *ng-for="#item of items; #i = index" [selected]="selected === item"(click)="updateSelection()">{{ item }}</option> </select>`, directives: [NgFor] }) class MyDisplay { items: string[]; constructor() { this.items = ["item1", "item2"]; } updateSelection() { … } } 

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


All Articles