You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importmockExternalfrom"./mock.js";functionmock<T>(arg?: T){}consta=mock();constb=mock();constc=mock<string>("aaaa");constd=mock/* meow */("arg1");// Note: force tsc to generate an indirect callconste=mockExternal("");
Compiled:
"use strict";var__importDefault=(this&&this.__importDefault)||function(mod){return(mod&&mod.__esModule) ? mod : {"default": mod};};Object.defineProperty(exports,"__esModule",{value: true});constmock_js_1=__importDefault(require("./mock.js"));functionmock(arg){}consta=mock();constb=mock();constc=mock("aaaa");constd=mock/* meow */("arg1");// Note: force tsc to generate an indirect callconste=(0,mock_js_1.default)("");//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5wdXQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbnB1dC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSx3REFBcUM7QUFFckMsU0FBUyxJQUFJLENBQUksR0FBTyxJQUFFLENBQUM7QUFFM0IsTUFBTSxDQUFDLEdBQUcsSUFBSSxFQUFFLENBQUM7QUFDakIsTUFBTSxDQUFDLEdBQUcsSUFBSSxFQUFLLENBQUM7QUFDcEIsTUFBTSxDQUFDLEdBQUcsSUFBSSxDQUFXLE1BQU0sQ0FBQyxDQUFDO0FBQ2pDLE1BQU0sQ0FBQyxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUssTUFBTSxDQUFJLENBQUM7QUFFekMsK0NBQStDO0FBQy9DLE1BQU0sQ0FBQyxHQUFHLElBQUEsaUJBQVksRUFBTyxFQUFFLENBQUcsQ0FBQyJ9
π Actual behavior
The JS is compiled perfectly and works fine, however due to the way NodeJS reports call sites the call site of each mock function invocation is as follows:
position in JS (line, col)
substring in JS at position
position after source mapping
substring in TS at position
(8, 11)
mock
(5, 11)
mock
(9, 11)
mock
(6, 11)
mock
(10, 11)
mock
(7, 11)
mock
(11, 11)
mock
(8, 11)
mock
(13, 31)
("");
(11, 29)
"" );
When looking at a call expressions reported call site I personally think that indirect call expressions positions are misleading after being source mapped as it seems to imply the first argument is the section of the code affected when there are spaces between the first argument and the open parenthesis token.
π Expected behavior
I would expect the (13,31) call site to map directly to (12, 27) in the source map, so that users can easily see the invocation position of the function call, in a consistent and predictable way.
Additional information about the issue
I debated on whether this would be considered a bug or a feature request, but decided on bug due to the current call site position being inconsistent for users trying to map their codes call location. If you think this should be a feature request, I am more than happy to change this issue to be a feature request.
If this feature is deemed to be an acceptable change to typescripts source map emissions, I have created a simple implementation that in my own testing seems to work, I am happy to add automated tests and raise a PR (https://github.com/mini-ninja-64/TypeScript/tree/improve-source-map). My current implementation works by emitting a source map position in the emitNodeList function based on the start position of the provided NodeArray<T>, this means it could also improve the source map production for other node lists; however this could increase the size of source maps generated by tsc.
The text was updated successfully, but these errors were encountered:
π Search Terms
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?module=1&inlineSourceMap=true#code/JYWwDg9gTgLgBCCBjA1gUQB4wKZQHYCGANnAGZQQhwBEAdAPSKq0BWAztQNwBQ3pArniQxgEPAmQoAPABUAfAAoCUAOYB+AFxwZASgDeAX15IxbeATgBeCagU6eJvGbgAjKzZRwFcOPe6PnJHcmaTMoYDwVOR8FagJ4gmo-APgAE2DJOHoAKgRsCAB3OGz6Lx8aZRUARmpyv256UoA5CBwtUmgkbDgYNiCYCDgVbDxcAhw4AnEI1OAobGE4JGIif1N4busQzBx8YnKymlrfHiA
π» Code
Compiled:
π Actual behavior
The JS is compiled perfectly and works fine, however due to the way NodeJS reports call sites the call site of each
mock
function invocation is as follows:mock
mock
mock
mock
mock
mock
mock
mock
("");
"" );
When looking at a call expressions reported call site I personally think that indirect call expressions positions are misleading after being source mapped as it seems to imply the first argument is the section of the code affected when there are spaces between the first argument and the open parenthesis token.
π Expected behavior
I would expect the (13,31) call site to map directly to (12, 27) in the source map, so that users can easily see the invocation position of the function call, in a consistent and predictable way.
Additional information about the issue
I debated on whether this would be considered a bug or a feature request, but decided on bug due to the current call site position being inconsistent for users trying to map their codes call location. If you think this should be a feature request, I am more than happy to change this issue to be a feature request.
If this feature is deemed to be an acceptable change to typescripts source map emissions, I have created a simple implementation that in my own testing seems to work, I am happy to add automated tests and raise a PR (https://github.com/mini-ninja-64/TypeScript/tree/improve-source-map). My current implementation works by emitting a source map position in the
emitNodeList
function based on the start position of the providedNodeArray<T>
, this means it could also improve the source map production for other node lists; however this could increase the size of source maps generated by tsc.The text was updated successfully, but these errors were encountered: