-
Notifications
You must be signed in to change notification settings - Fork 12.8k
incorrect source map #4003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It seems like turning preserveComments off might fix this...at least my first attempt at debugging stopped at a breakpoint I had been missing. |
There's a possibility this is related to #2546 - it looks like it surfaces in the same circumstances. |
I'm seeing this same issue with a project I'm working on. |
@weswigham they might be related... It seems the compiler is not updating the source map internally wit the current position when consuming a comment. I just ran across this one (the source file maps being wrong with Here is a link to a visualisation of the following: Given this function foo(str: string, num: number): void {
return;
}
/**
* some sort of block quote
*/
function bar(str: string, num: number): void {
return;
}
// some sort of comment
function baz(str: string, num: number): void {
return;
}
function qat(str: string, num: number): void {
return;
} The following will be emitted: function foo(str, num) {
return;
}
/**
* some sort of block quote
*/
function bar(str, num) {
return;
}
// some sort of comment
function baz(str, num) {
return;
}
function qat(str, num) {
return;
}
//# sourceMappingURL=sourcemap.js.map With the following map: {
"version":3,
"file":"sourcemap.js",
"sourceRoot":"",
"sources":["sourcemap.ts"],
"names":["foo","bar","baz","qat"],
"mappings":"AACA,aAAa,GAAW,EAAE,GAAW;IACjCA,MAAMA,CAACA;AACXA,CAACA;AAKD,AAHA;;GAEG;aACU,GAAW,EAAE,GAAW;IACjCC,MAAMA,CAACA;AACXA,CAACA;AAGD,AADA,uBAAuB;aACV,GAAW,EAAE,GAAW;IACjCC,MAAMA,CAACA;AACXA,CAACA;AAED,aAAa,GAAW,EAAE,GAAW;IACjCC,MAAMA,CAACA;AACXA,CAACA"
} |
Incidentally, I tried switching to VS Code (using the same tsconfig file) to see if I could move off of IntelliJ. Breakpoints in Code often seem not to get hit (where IntelliJ works fine). I assume this means that there are also some problems with Code breakpoint setting that aren't sourcemap problems. |
Thank you @sheetalkamat!!!!! 😄 |
I think the source maps being generated are incorrect in some instances. I had an IntelliJ 'node' project working in 1.5.0-beta that experienced debugging problems (not stopping at some breakpoints, and not stopping at each line when stepping) when I moved to 1.5.3. I have tracked down the problem (I think) to a difference in the source maps being generated if there are comments involved. Some simplified code:
These json options:
"removeComments": false,
"preserveConstEnums": true,
"sourceMap": true,
"noImplicitAny":true,
"suppressImplicitAnyIndexErrors":true,
"target": "ES5",
1.5.0-beta sourcemap data: {"version":3,"file":"Test.js","sourceRoot":"","sources":["sourceMapTest/sas/tools/Test.ts"],"names":["sas","sas.tools","sas.tools.Test","sas.tools.Test.constructor","sas.tools.Test.doX"],"mappings":"AAAI,IAAO,GAAG,CAsBT;AAtBD,WAAO,GAAG;IAACA,IAAAA,KAAKA,CAsBfA;IAtBUA,WAAAA,KAAKA,EAChBA,CAACA;QACGC;YAAAC;YAkBAC,CAACA;YAhBUD,kBAAGA,GAAVA;gBAEIE,IAAIA,CAACA,GAAQA,CAACA,CAACA;gBACfA,MAAMA,CAACA,CAACA,CAACA,CAACA,CACVA,CAACA;oBACGA,KAAKA,CAACA;wBACFA,KAAKA,CAACA;oBACVA,KAAKA,CAACA;wBACFA,gBAAgBA;wBAChBA,gBAAgBA;wBAChBA,KAAKA,CAACA;oBACVA,KAAKA,CAACA;wBACFA,WAAWA;wBACXA,KAAKA,CAACA;gBACdA,CAACA;YACLA,CAACA;YACLF,WAACA;QAADA,CAACA,AAlBDD,IAkBCA;QAlBYA,UAAIA,OAkBhBA,CAAAA;IAELA,CAACA,EAtBUD,KAAKA,GAALA,SAAKA,KAALA,SAAKA,QAsBfA;AAADA,CAACA,EAtBM,GAAG,KAAH,GAAG,QAsBT"}
1.5.3 sourcemap data: {"version":3,"file":"Test.js","sourceRoot":"","sources":["sourceMapTest/sas/tools/Test.ts"],"names":["sas","sas.tools","sas.tools.Test","sas.tools.Test.constructor","sas.tools.Test.doX"],"mappings":"AAAA,IAAO,GAAG,CAsBT;AAtBD,WAAO,GAAG;IAACA,IAAAA,KAAKA,CAsBfA;IAtBUA,WAAAA,KAAKA,EAChBA,CAACA;QACGC;YAAAC;YAkBAC,CAACA;YAhBUD,kBAAGA,GAAVA;gBAEIE,IAAIA,CAACA,GAAQA,CAACA,CAACA;gBACfA,MAAMA,CAACA,CAACA,CAACA,CAACA,CACVA,CAACA;oBACGA,KAAKA,CAACA;wBACFA,KAAKA,CAACA;oBACVA,KAAKA,CAACA;wBAGFA,AAFAA,gBAAgBA;wBAChBA,gBAAgBA;wBAChBA,KAAKA,CAACA;oBACVA,KAAKA,CAACA;wBAEFA,AADAA,WAAWA;wBACXA,KAAKA,CAACA;gBACdA,CAACA;YACLA,CAACA;YACLF,WAACA;QAADA,CAACA,AAlBDD,IAkBCA;QAlBYA,UAAIA,OAkBhBA,CAAAA;IAELA,CAACA,EAtBUD,KAAKA,GAALA,SAAKA,KAALA,SAAKA,QAsBfA;AAADA,CAACA,EAtBM,GAAG,KAAH,GAAG,QAsBT"}
There are two differences, both at the comments inside the switch cases. In both cases, the 1.5.3 map reports an entry at
The main difference seems to be that the beta map lists (12, 20) as a location, while the 1.5.3 version doesn't (it lists 14, 20) instead. The line returned appears to be the start of the last comment after the case keyword. I don't know much about source maps, but I assume that the debugger is adding a breakpoint at a location that isn't valid, so the debugger just misses those locations.
The text was updated successfully, but these errors were encountered: