get topLeft() { return this._topLeft; }
set topLeft(value) { this._topLeft = value; Recalc(); }
上面的代碼作品打字稿播放找到,但是從Visual Studio 2012 error "exited with code 1"
編譯打字稿錯誤代碼「退出,代碼爲1」
有誰試圖獲得編譯時我收到生成錯誤 ,在TypeScript中設置並建立成功?
get topLeft() { return this._topLeft; }
set topLeft(value) { this._topLeft = value; Recalc(); }
上面的代碼作品打字稿播放找到,但是從Visual Studio 2012 error "exited with code 1"
編譯打字稿錯誤代碼「退出,代碼爲1」
有誰試圖獲得編譯時我收到生成錯誤 ,在TypeScript中設置並建立成功?
您需要定位ECMAScript v5,即將-target ES5
參數傳遞給編譯器。這需要在項目文件目標配置中進行設置。
我不知道VS是否有內置的mechanims來編輯目標配置,所以我只能告訴你如何手動完成它。只需打開.csproj
項目文件,查找TypeScript編譯器命令所在的Target
節點,然後添加-target ES5
參數。
在我的配置它看起來像這樣:
<Target Name="BeforeBuild">
<Exec Command=""$(PROGRAMFILES)\Microsoft SDKs\TypeScript\0.8.0.0\tsc" -target ES5 @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
</Target>
更新
截至0.8.1.0版本後,除去硬編碼的版本依賴,並添加源地圖的支持,所以Target
節點現在看起來是這樣的默認:
<Target Name="BeforeBuild">
<Message Text="Compiling TypeScript files" />
<Message Text="Executing tsc$(TypeScriptSourceMap) @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
<Exec Command="tsc$(TypeScriptSourceMap) @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
</Target>
注入target
申辯換貨還是蠻容易的,簡單地把它tsc
或$(TypeScriptSourceMap)
後:
<Message Text="Executing tsc --target ES5 $(TypeScriptSourceMap) @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
<Exec Command="tsc --target ES5 $(TypeScriptSourceMap) @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
由於0.8.2又是一個變化。一些常見的TypeScript構建材料已從您的.csproj移至外部構建文件。像這樣:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" />
你的.csproj仍然得到通過,包括它們作爲構建元素設置的打字稿構建一些參數。其中一個元素是ES版本。該模板創建兩組對我來說,一個用於調試,一個用於發佈:
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptTarget>ES3</TypeScriptTarget>
<TypeScriptIncludeComments>true</TypeScriptIncludeComments>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TypeScriptTarget>ES3</TypeScriptTarget>
<TypeScriptIncludeComments>false</TypeScriptIncludeComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
</PropertyGroup>
了預期的效果只是改變ES3到ES5
爲了更深入地瞭解如何最終結束了作爲部分調用TypeScript編譯器可以看一下Microsoft.TypeScript.targets文件。
祝你好運,
我編輯TypeScriptTarget到ES5後我得到的錯誤:'「tsc.exe」退出代碼1.'任何想法? – daniel
非常感謝你......它就像一個魅力...^_ ^ÿ – DexDude
不客氣:)請注意,它的建議,以紀念在問題解決了這個問題的答案(它旁邊的小複選標記),它不僅關乎聲譽,還幫助其他人選擇正確的信息(假設有更多的答案),這是其他問題解決者和受訪者解決的指標,以及其他人當他們發現它不會是空話時,會更加鼓勵他們回答你的問題。 – ndm
我的BeforeBuild目標有一個Exec Command = tsc $(TypeScriptSourceMap)@ ...行,而不是" $(PROGRAMFILES)...你提到的一個。我錯誤地安裝了一些東西嗎?你知道在哪裏把ES5目標與這種Exec Command風格相提並論嗎? – GaryB96