typescript Type Script 未在我的 Visual Studio 社区版 2015 中生成 JavaScript
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31845721/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Type Script is not generating JavaScript in my Visual Studio Community edition 2015
提问by kudlatiger
I am using Visual Studio Community edition 2015for development, I have added *.ts file to my project but its not automatically compiling. Also it does not show JavaScript preview pane. This post How do I enable the preview panel for TypeScript files in Visual Studio 2015?says that it's not supported anymore. That's fine, but why it's not compiling?
我正在使用Visual Studio Community edition 2015进行开发,我已将 *.ts 文件添加到我的项目中,但它不会自动编译. 它也不显示 JavaScript 预览窗格。这篇文章如何在 Visual Studio 2015 中启用 TypeScript 文件的预览面板?说它不再受支持。那很好,但为什么它不编译?
I referenced Missing Typescript Options in Web Essential for Visual Studio 2012
我在 Visual Studio 2012 的 Web Essential 中引用了Missing Typescript Options
It says Split panes have been reintroducedin the latest version of web essentials http://vswebessentials.com/features/typescriptbut I can not see it
它说已在最新版本的 Web Essentials 中重新引入了拆分窗格http://vswebessentials.com/features/typescript但我看不到它
I do have typescript exe in following folder
我在以下文件夹中有打字稿 exe
C:\Program Files (x86)\Microsoft SDKs\TypeScript.5
I do have settings in Project Properties as follow
我在项目属性中有如下设置
I do have settings as follow in Visual Studio
我在 Visual Studio 中有如下设置
I see comment in http://www.typescriptlang.org/as below
我在http://www.typescriptlang.org/看到评论如下
"Visual Studio includes TypeScript in the box, starting with Visual Studio 2013 Update 2. You can also edit TypeScript in VS Code, WebStorm, Atom, Sublime Text, and Eclipse"
“Visual Studio 在框中包含 TypeScript,从 Visual Studio 2013 Update 2 开始。您还可以在 VS Code、WebStorm、Atom、Sublime Text 和 Eclipse 中编辑 TypeScript”
What may be issue?
可能有什么问题?
Solution
解决方案
My "typings" file for jquery was out dated, I upgraded it and it resolved other errors and build was success, then JS files got generated.
我的 jquery “类型”文件已经过时,我升级了它并解决了其他错误并且构建成功,然后生成了 JS 文件。
Below post helped JQuery definition screwed up with TypeScript 0.9
下面的帖子帮助 JQuery 定义搞砸了 TypeScript 0.9
I can not close this question because I am still not able to get 'Preview Pane"
我无法关闭这个问题,因为我仍然无法获得“预览窗格”
回答by Jon Preece
I regularly encounter this issue in VS 2015 and VS 2013. My solution is not a pretty one, but it works for me...
我经常在 VS 2015 和 VS 2013 中遇到这个问题。我的解决方案不是很好,但它对我有用......
- Close Visual Studio
- Go to your scripts folder, delete all JavaScript files that have corresponding TypeScript files (only necessary to do this for TypeScript files that you have created for your project)
- Open Visual Studio, clean, and build
- 关闭 Visual Studio
- 转到您的脚本文件夹,删除所有具有相应 TypeScript 文件的 JavaScript 文件(仅需要为您为项目创建的 TypeScript 文件执行此操作)
- 打开 Visual Studio,清理并构建
If this doesn't work, open each TypeScript file, change one character, Save, re-build... hopefully the file will re-compile.
如果这不起作用,请打开每个 TypeScript 文件,更改一个字符,保存,重新构建...希望该文件能够重新编译。
If this still doesn't work, open a Node.JS command prompt, change directory to the scripts directory, run;
如果这仍然不起作用,请打开 Node.JS 命令提示符,将目录更改为脚本目录,运行;
tsc "yourfile.ts"
If this doesn't work, you've got bigger problems.
如果这不起作用,您将遇到更大的问题。
回答by pat capozzi
Make sure that you highlight the project in the solution explorer and then click the icon at the top that says "show all files" after you have compiled the project. You will then see the .js and maybe a .js.map file (greyed out). Select the files and then right click and 'include in project' and things should be good from there.
确保在解决方案资源管理器中突出显示项目,然后在编译项目后单击顶部显示“显示所有文件”的图标。然后您将看到 .js 和一个 .js.map 文件(变灰)。选择文件,然后右键单击并“包含在项目中”,然后一切都会好起来的。
回答by Rm558
回答by Zinov
Maybe not having the option to expand the .ts file and see the generated .js can cause a confusion here.Try to compile your solution. Click on Show All Files and you must see all the .js generated in the same folder of your .ts files. Include your .js in the project if you want to have them visible as part of the solutions. Hope this helps
也许没有选项可以展开 .ts 文件并查看生成的 .js 可能会在此处造成混淆。尝试编译您的解决方案。单击 Show All Files,您必须看到在 .ts 文件的同一文件夹中生成的所有 .js。如果您想让它们作为解决方案的一部分可见,请将您的 .js 包含在项目中。希望这可以帮助
回答by Chris Halcrow
I know you say you added the .ts file but did you right-click and select 'include in project'. This will add it to the list of files that Visual Studio will check for TypeScript transpiling.
我知道您说您添加了 .ts 文件,但是您是否右键单击并选择“包含在项目中”。这会将其添加到 Visual Studio 将检查 TypeScript 转译的文件列表中。
回答by Software Enginner
You need install Web Essential then restart the Visual studio -> clean Solution -> Rebuild it should work.
您需要安装 Web Essential,然后重新启动 Visual Studio -> 清理解决方案 -> 重建它应该可以工作。