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?
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.