Vscode: Consider surfacing mapped variable names

Created on 15 Sep 2016  Â·  10Comments  Â·  Source: microsoft/vscode

Sourcemaps can represent variable name mappings, like when they're changed in minified code, or TypeScript's this => _this. Chrome DevTools shows the original variable names in their variables sidebar: https://bugs.chromium.org/p/chromium/issues/detail?id=327092

One problem is that if you don't know the original names, you can't inspect them in the console or with watches. But I think it would still make debugging easier to have them just in the variables pane.

We could go one step further by showing both names, in the variable name space, just like myArray (t). And another step by adding this to the protocol so that the context menu "Add to Watch" would work. I don't know if it's a useful concept outside of JS though.

debug feature-request

Most helpful comment

I am still observing many related issues especially when typescript got compiled, such as typescript rename 'this' to '_this", or the variable names got minified somehow, arrow function context. This issue is really annoying to customers, and it makes VsCode debugger not useful sometimes. I think this feature should be considered with higher priority.

All 10 comments

This is a great feature request, however after discussing with @weinand we would need an AST understanding of the language in order to support this feature. Since the source map talks about the location in the file and there is no other correlation between the minified name and the original one.

We should investigate in the future what it would take for us to have a better understanding of the AST and decide if that logic should live on the vscode or the debug adapter side.
Unassigning myself since I am not a fan of multi-assigned issues :)

Other areas which would profit from a better AST understanding are the debug hover and showing evaluted variables inlined.

Does the debug adapter expose an api to get mapped names per line?

I believe source map does expose how a variable in source code is mapped to transpiled code, right?

The debug adapter returns the list of variables to vscode, so if we wanted to show the variables from TS, the debug adapter would do that mapping. The source-map library that vscode-chrome-debug-core uses exposes an API for this.

@nojvek source map support is an implementation detail of a debug adapter that does not leak through the API to VS Code. So VS Code does not know anything about source maps.

The source map specification defines naive support for symbol mappings (as opposed to range mapping), but I do not see how that can be used in practice without scope information. So something is missing here...

In addition I do not see broad support for symbol mappings in transpile tools. E.g. TypeScript (tsc) leaves the symbol mapping always empty and I'm not aware of a tsc option to turn symbol mappings on.

This seems like a bug in Typescript not emitting names. Filed:
https://github.com/Microsoft/TypeScript/issues/14688

So are you saying, once you have names correctly outputted in sourcemaps
(babel does this), you are able to make this work?

For my scenario, I will try to bypass ES5 output and just go directly to
ES6.

On Thu, Mar 16, 2017 at 5:02 AM Andre Weinand notifications@github.com
wrote:

@nojvek https://github.com/nojvek source map support is an
implementation detail of a debug adapter that does not leak through the API
to VS Code. So VS Code does not know anything about source maps.

The source map specification defines naive support for symbol mappings (as
opposed to range mapping), but I do not see how that can be used in
practice without scope information. So something is missing here...

In addition I do not see broad support for symbol mappings in transpile
tools. E.g. TypeScript (tsc) leaves the symbol mapping always empty and I'm
not aware of a tsc option to turn symbol mappings on.

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/Microsoft/vscode/issues/12066#issuecomment-287036761,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA-JVFA1PxwYrhT7-gooVDk7_hvMIhRgks5rmSTvgaJpZM4J9pi6
.

Maybe, I think we don't yet have a good understanding of the work involved to make it work.

@roblourens can the problem with sourcemaps be fixed now? It's been half of the year since last activity here and many TypeScript versions came in.

I am still observing many related issues especially when typescript got compiled, such as typescript rename 'this' to '_this", or the variable names got minified somehow, arrow function context. This issue is really annoying to customers, and it makes VsCode debugger not useful sometimes. I think this feature should be considered with higher priority.

This is true - I'm trying to switch from Webstorm to VSCode and this makes the debugger virtually useless...how can you debug typescript code if you can't see the actual variables as they are named in the ts code?! Webstorm does this no problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukehoban picture lukehoban  Â·  3Comments

omidgolparvar picture omidgolparvar  Â·  3Comments

NikosEfthias picture NikosEfthias  Â·  3Comments

v-pavanp picture v-pavanp  Â·  3Comments

DovydasNavickas picture DovydasNavickas  Â·  3Comments