顯示具有 TypeScript 標籤的文章。 顯示所有文章
顯示具有 TypeScript 標籤的文章。 顯示所有文章

2016年5月13日 星期五

VS2015 TypeScript "Compile On Save" options is disabled!

在 Improved support for tsconfig.json in Visual Studio 2015 提到 VS2015 已支援 tsconfig.json,
但發現一個問題,在 VS2015 中,我直接對 *.ts 進行儲存,卻不會立即編譯 ts 檔,
必須要 rebuild 專案才會編譯,這也太無法讓人接受了吧!

經一番 google 才發現,原來專案加入 tsconfig.json 後,預設是關閉 compile on save 的,
那該如何設定才能開啟呢?

  1. 找到 VS2015 Tools\Options\Text Editor\TypeScript\Project 頁面
  2. 勾選 "Automatically compile typescript files which are not part of a project"
  3. 重啟 VS2015




2016年5月12日 星期四

Improved support for tsconfig.json in Visual Studio 2015

原來 typescript 1.8 已改善 Visual Studio 2015 支援 tsconfig.json,
在編譯 *.ts 檔時,依 tsconfig.json 的參數進行 ( release note )
( includes ASP.NET v4 projects )

在未支援前,還要直接修改專案檔,如下:

現在只要在專案加入 tsconfig.json ,依需求設定參數即可
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}


在專案檔 typescript 參數設定頁面就會被設為不可編輯,如下:


這樣真的就方便多了,不用再煩惱啦!