2016-12-06 50 views
2

我安裝了Visual Studio代碼(版本1.7.2)並打印了1.8版本。我已經在一個文件夾中構建了一個簡單的react-native項目。 (反應應用程序工作得很好,因爲我可以在調試器中運行它)。現在我嘗試整合打字稿。但vs代碼不會在保存(ctrl + s)和構建(ctrl + b)上都不傳輸我的代碼。這裏是我的tsconfig.json文件(位於我的項目的根目錄):vs code not transpiling ts files

{ 
    "compilerOptions": { 
    "target": "es5", 
    "module": "commonjs",  
    "sourceMap": true, 
    "noImplicitAny": true   
    }, 
    "compileOnSave": true, 
    "exclude": [ 
    "node_modules" 
    ] 
} 

這裏是tasks.json文件:爲VS代碼能夠挑語法錯誤從

{ 
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format 
    "version": "0.1.0", 
    "command": "C:\\Program Files (x86)\\Microsoft SDKs\\TypeScript\\1.8\\tsc", 
    "isShellCommand": true, 
    "args": ["-p", "."], 
    "showOutput": "always", 
    "problemMatcher": "$tsc" 
} 

編譯發生就好了測試文件calle「mytest.ts」 但是在保存或構建時沒有生成「mytest.js」文件。我已按照此指示https://code.visualstudio.com/Docs/languages/typescript

仍然我無法獲得vs代碼transpile我的代碼。

任何幫助,暗示朝着正確的方向將不勝感激。

預先感謝您

回答

1

我終於能夠通過修改tasks.json文件中像這樣來解決我的問題:

{ 
    ... 

    "args": ["-p", "${workspaceRoot}"], 

    ... 

}