Skip to content
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

Consider surfacing mapped variable names #12066

Closed
roblourens opened this issue Sep 15, 2016 · 11 comments
Closed

Consider surfacing mapped variable names #12066

roblourens opened this issue Sep 15, 2016 · 11 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality on-testplan
Milestone

Comments

@roblourens
Copy link
Member

roblourens commented Sep 15, 2016

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.

@roblourens roblourens added feature-request Request for new features or functionality debug Debug viewlet, configurations, breakpoints, adapter issues labels Sep 15, 2016
@isidorn
Copy link
Contributor

isidorn commented Sep 19, 2016

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.

@nojvek
Copy link
Contributor

nojvek commented Mar 15, 2017

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?

@roblourens
Copy link
Member Author

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.

@weinand
Copy link
Contributor

weinand commented Mar 16, 2017

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

@nojvek
Copy link
Contributor

nojvek commented Mar 16, 2017 via email

@roblourens
Copy link
Member Author

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

@roblourens
Copy link
Member Author

@Lazarencjusz
Copy link

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

@gynet
Copy link

gynet commented Oct 15, 2019

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.

@themaskedavenger
Copy link

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.

@connor4312
Copy link
Member

connor4312 commented May 14, 2021

We now support this, in today's nightly. There is even limited support in the evaluation contexts, like the REPL and "watch" view.

image

REPL completions for renamed variables don't work, and this isn't supported in conditional breakpoints.

@connor4312 connor4312 added the verification-needed Verification of issue is requested label May 14, 2021
@connor4312 connor4312 added on-testplan and removed verification-needed Verification of issue is requested labels Jun 1, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jun 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality on-testplan
Projects
None yet
Development

No branches or pull requests

8 participants