本文介绍了Typescript在保存上编译无法在Cordova .jsproject中工作-2015的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Visual Studio 2015安装了Typescript 1.5 beta工具,并创建了一个新的Cordova Typescript项目.项目模板包含一些.ts文件,但我无法在保存时将其编译.

I have Typescript 1.5 beta tools for Visual Studio 2015 installed, and I create a new Cordova Typescript project. The project template includes some .ts files but I cannot get these to compile on save.

奇怪的是,如果我使用带有Typescript模板的HTML 5创建新项目,则app.ts文件会在保存时进行编译.仅在此.jsproj cordova项目中,它会忽略TypeScript编译.为什么?

Strangely if I create a new project using the Html 5 with Typescript template, the app.ts file does compile on save. It's only in this .jsproj cordova project that it ignores TypeScript compilation. Why?

我看到它们使用不同的目标(对于Html 5项目使用Microsoft.Typescript.targets,而在cordova项目中使用Microsoft.TypeScript.MDA.targets:

I see that they use different targets (for the Html 5 project uses Microsoft.Typescript.targets where as in the cordova project is uses Microsoft.TypeScript.MDA.targets:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\ApacheCordovaTools\vs-mda-targets\Microsoft.TypeScript.MDA.targets" />

对于这两种情况,我都验证了文件分别位于各自的位置.我什至尝试使用非MDA目标.没运气.我还在项目的根目录中包含一个空的tsconfig.json文件,仍然没有运气.

For both cases I verified the files exist in their respective locations. I even tried to use the non MDA target instead; no luck. I also included an empty tsconfig.json file at the root of the project, still no luck.

如何像其他项目类型一样保存Typescript文件进行编译?

How can I get Typescript file to compile on save like they do in other project types?

我还具有ENABLED工具>选项>文本编辑器>打字稿>编译不属于项目以及已安装的Web Essentials 2015的文件...什么都不起作用!

I also have ENABLED Tools > Options > Text Editor> Typescript > Compile files that are not part of the project as well as installed Web Essentials 2015... Nothing works!

推荐答案

您可以使用以下方法进行简单设置:工具>选项>文本编辑器> TypeScript>项目>常规,然后选中保存时编译",然后单击确定".然后你去.

You could simple to setup use: Tools > Options > Text Editor > TypeScript > Project > General, and check "Compile on Save" then OK. And here you go.

我使用称为"grunt-ts"的任务运行程序的另一种方式,我更喜欢使用任务运行程序来帮助我编译.ts文件,它还提供了包括监视功能在内的详细功能.

Another way I'm used task runner called "grunt-ts" to do so, I'm prefer to use task runner to help me to compiled the .ts file, it also provide detail feature include watch to do so.

这篇关于Typescript在保存上编译无法在Cordova .jsproject中工作-2015的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 18:50