typescript debug / breakpoint does not work

纵饮孤独 提交于 2020-01-11 04:59:06

问题


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

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'

  • Any help?

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

Thank in advance

Richard


回答1:


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.

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




回答2:


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

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




回答3:


Here is the answer (of my question ... with the help of 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

I found the problem because:

  1. The //# sourceMappingURL=/path/to/file.js.map was 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..

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

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 :-(

Thank and I hope it will help others.




回答4:


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.



来源:https://stackoverflow.com/questions/19752408/typescript-debug-breakpoint-does-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!