Browser error messages referencing correct typescript file using outFile

I am using the outFile option in the tsconfig.json to compile my typescript files into one .js file. I am generating a source map. Error messages are not referenced to the typescript file though.

Examples:


script.ts: throw 'Error' tsconfig.json:

{
  "compilerOptions": {
    "sourceMap": true
  }
}

Compiling (tsc 1.6.2) will generate: script.js: throw 'Error script.js.map: {"version":3,"file":"script.js","sourceRoot":"","sources":["script.ts"],"names":[],"mappings":"AACA,MAAM,QAAQ,CAAC"}

The browser's console (Chrome 47.0.2526.73 m) will display: Uncaught Error. script.ts:1

That's just fine.


script.ts: throw 'Error' tsconfig.json:

{
  "compilerOptions": {
    "sourceMap": true,
    "outFile": "app.js"
  }
}

Compiling (tsc 1.6.2) will generate: app.js: throw 'Error app.js.map: {"version":3,"file":"app.js","sourceRoot":"","sources":["script.ts"],"names":[],"mappings":"AACA,MAAM,QAAQ,CAAC"}

The browser's console (Chrome 47.0.2526.73 m) will display: Uncaught Error. app.js:1

It is app.js it should be app.ts

How can I get the browser to reference error messages to my typescript files?

Answers


I have used the same version of Chrome browser. However ts compiler version is 1.7.3

Dev tools console is opened.

1 case:

  • ts.config

    { "compilerOptions": { "sourceMap": true } }

  • app.ts

    throw 'some error in my typescript';

  • dev tools console:

    app.ts:5Uncaught some error in my typescript(anonymous function) @ app.ts:5

2 case:

  • ts.config

    { "compilerOptions": { "sourceMap": true, "outFile": "src.js" } }

  • app.ts

    throw 'some error in my typescript';

  • dev tools console:

    app.ts:5Uncaught some error in my typescript(anonymous function) @ app.ts:5

If a dev tools console is closed, the page is refreshed, then you will open the dev tools console, then you can see the following:

src.js:4 Uncaught some error in my typescript

But if you refresh the page again with opened dev tools console, you can see ts file as a source of error.


Need Your Help

Programmatically open a text file in R?

r

Is there something in R to open a text file? In Python, one could open a text file using notepad:

trivially default constructible std::optional and std::variant

c++ c++11 c++14 optional variant

Is it permitable to design std::optional (currently std::experimental::optional) in such a way, that for trivially default constructible type T corresponding std::optional< T > is also trivia...