typescript 打字稿调试/断点不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19752408/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:52:15  来源:igfitidea点击:

typescript debug / breakpoint does not work

debuggingtypescript

提问by rlasjunies

Since few days, debugger does not work anymore. I've tried several things without success.

几天后,调试器不再工作。我尝试了几件事但没有成功。

  • typescript 0.9.1
  • VS2012
  • IE10
  • the source map, JS files are updated when I save the TS files
  • 打字稿 0.9.1
  • VS2012
  • IE10
  • 源映射,JS 文件在我保存 TS 文件时更新

In Visual studio at the place of the breakpoint I've got: 'The breakpoint will not currently be hit. No symbols have been loaded for this document'

在 Visual Studio 中的断点处,我得到了:'当前不会命中断点。尚未为该文档加载任何符号'

  • Any help?

  • How IE load the symbols? I assume it's related to the source map ...

  • 有什么帮助吗?

  • IE如何加载符号?我认为它与源地图有关......

Thank in advance

预先感谢

Richard

理查德

采纳答案by rlasjunies

Here is the answer (of my question ... with the help of WiredPrairie, ... ;-) )

这是答案(我的问题......在WiredPrairie的帮助下...... ;-))

This line

这条线

<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" Condition="'$(BuildingInsideVisualStudio)' == 'true'" />

was preceeding my lines

在我的台词之前

 <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <TypeScriptTarget>ES5</TypeScriptTarget>
    <TypeScriptRemoveComments>true</TypeScriptRemoveComments>
    <TypeScriptSourceMap>true</TypeScriptSourceMap>
    <TypeScriptModuleKind>AMD</TypeScriptModuleKind>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <TypeScriptTarget>ES5</TypeScriptTarget>
    <TypeScriptRemoveComments>true</TypeScriptRemoveComments>
    <TypeScriptSourceMap>true</TypeScriptSourceMap>
    <TypeScriptModuleKind>AMD</TypeScriptModuleKind>
  </PropertyGroup>

So I put it AFTER ( what a smart guys, isn't it ;-) ) in my *.csproj

所以我把它放在我的 *.csproj 之后(多么聪明的家伙,不是吗;-))

I found the problem because:

我发现了这个问题,因为:

  1. The //# sourceMappingURL=/path/to/file.js.mapwas generated at the end of the *.js files when saving, not when compiling.

  2. The build output was saying The TypeScript Compiler was given an empty configurations string, which is unusual and suspicious..

  1. //# sourceMappingURL=/path/to/file.js.map保存时,不编译时是在* .js文件的末尾生成。

  2. 构建输出说The TypeScript Compiler was given an empty configurations string, which is unusual and suspicious.

The solution comes from this post: TypeScript Compiler was given an empty configurations string.

解决方案来自这篇文章:TypeScript Compiler 被赋予一个空的配置字符串

The root cause of the problem appears when I tried to deploy my project to Azure. The js files were not uploaded/compiled, so i've added this tricky line in the csproj bad luck :-(

当我尝试将我的项目部署到 Azure 时,问题的根本原因出现了。js 文件没有上传/编译,所以我在 csproj 不幸中添加了这个棘手的行:-(

Thank and I hope it will help others.

谢谢,我希望它会帮助别人。

回答by Mika Berglund

I had a similar problem, but with Visual Studio 2013. No breakpoints were hit, even though I was running in debug mode and with source maps generated.

我有一个类似的问题,但在 Visual Studio 2013 中。没有断点,即使我在调试模式下运行并生成了源映射。

I found out that after I included the compiled .js files in the project, my breakpoints in TypeScript started hitting.

我发现在项目中包含编译好的 .js 文件后,我在 TypeScript 中的断点开始命中。

回答by Dmitry Matveev

The following is for people who are using Chrome or Firefoxfor the environment...

以下是针对使用Chrome 或 Firefox环境的人...

Apparently you just simply can't get it to work with VS but not all is lost as the author of thisarticle shows. Hope it helps some more struggles to get debugging :)

显然,你刚才根本无法得到它与VS工作,但不是全部损失为笔者文章显示。希望它有助于更​​多的调试工作:)

回答by MiN

In my case the answer was that another script file was actually used by the html. Once this was fixed, breakpoints started working, of course.

就我而言,答案是 html 实际使用了另一个脚本文件。一旦修复了这个问题,断点当然就开始工作了。