Visual Studio 2015とともに、TypeScript 1.5がリリースされました

ご存知のように、Visual Studio 2015は昨夜リリースされましたが、同時に、MicrosoftはTypeScript 1.5の最終バージョンを新しいVisual Studioに含めて導入しました。 VSの以前のバージョン用に個別にダウンロードするか、npmを使用してインストールすることもできます。 カットの下-新しいリリースで興味深いものの短いリスト。







部分的なES6構文のサポート





MicrosoftはTypeScriptにES6との下位互換性を持たせたいと考えており、新しいリリースごとに体系的に新しい標準の構文を追加しています。 バージョン1.5は、特にモジュールのES6構文、構造化省略演算子for ... of文字計算されたプロパティlet / constサポート文字列 標準化の イテレーションが豊富です。 弦の標準化、カール!



モジュールシステムの改善





モジュールのES6構文のサポートに加えて、2つの新しいモジュール読み込み形式へのコンパイルが追加されました:SystemJSとUMD。 既にサポートされているCommonJSおよびAMDとともに、生成されたコードのモジュールをロードするための4つのオプションのいずれかを選択できます。



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







また、開発チームは内部モジュールの名前を「名前空間」に変更したため、「typescriptモジュール」と「typescript外部モジュール」は同じものになりました。 彼らは、新しい開発者が不満を言い、混乱したと言います。



Tsconfig.json構成ファイル





コンパイルおよびコンパイラ設定用のファイルのリストを指定できます。



 { "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デコレータ





ES7標準はまもなく安定しませんが、TypeScriptは実験モードではありますが、すでに新しいデコレータ構文を使用できます。



 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() { … } }
      
      






All Articles