0
votes

I have hello world program on typescript:

function say(msg: string) {
    alert(msg);
    for (let i:number=0;i<10;i++)
        document.write(i+"<br/>");
}
var msg:string="hello typescript world!";
say(msg);

this code is inside src folder. When I run compiler (tsc) it successfully generates *.js and *.map files and put them inside src folder.Also there is index.html in the root of the project

<html>
<body>
<script type="text/javascript" src="src/hello.js"></script>
</body>
</html>

But when I run debug session in chrome my breakpoints are ignored with the message

Breakpoint ignored because generated code not found (source map problem?)

In the web server logs I can see following line:

"GET /src/hello.js.map" "undefined"

tsconfig.json:

{
  "compilerOptions": {
    "sourceMap":true,
    "target": "es5",
    "module": "commonjs",
    "noImplicitAny": false
  }
}

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Debug in Chrome",
            "url": "http://localhost:8080",
            "webRoot": "${workSpaceRoot}"
        }
    ]
}

UPDATE: When trying to set breakpoint with chrome debugging tool it does stop on breakpoint but doesn't show my js/ts code:
breakpoint added breakpoint added

breakpoint reached breakpoint reached

2
What happens if you try to browse to the /src/hello.js.map file in chrome? 404 not found? - Arg0n
Did you install the chrome debug extension in VS Code? - Kokodoko
@Kokodoko Yes I've installed debug extension - undefined
@Arg0n What do you mean by browse in chrome? - undefined
In the address field: go to http://localhost:8080/src/hello.js.map, does the file show as text, or does it not return the file at all? Might be a file type issue with your server. - Arg0n

2 Answers

0
votes

It looks like there is an issue with VS code.I started new project with exactly the same launch.json,tsconfig.json and source code and its debugging ok in chrome!Then I copied everything into my initial project and now its debugging ok too.

0
votes

Go to settings (click "F1") and disable the option "Enable Javascript source maps".