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

Issue with debugging “this” in VS2013 when using lambdas #2617

Closed
fwanicka opened this issue Apr 4, 2015 · 4 comments
Closed

Issue with debugging “this” in VS2013 when using lambdas #2617

fwanicka opened this issue Apr 4, 2015 · 4 comments
Labels
Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript Visual Studio Integration with Visual Studio

Comments

@fwanicka
Copy link

fwanicka commented Apr 4, 2015

I am converting some TypeScript code from using a hard-coded capture of "this":

var _this = this;
var querySucceeded = function(data){
    this.doSomething(data);
}
var test = this.executeQuery().then(function(data){
    _this.querySucceeded(data);
});

to using lambdas:

var querySucceeded = function(data){
    this.doSomething(data);
}
var test = this.executeQuery().then((data) => {
    this.querySucceeded(data);
});

TypeScript compiles the JS into something resembling the first code block and everything runs fine in the browser. The issue is when debugging in Visual Studio. When I inspect "this" after the lambda, it shows the window properties, instead of the class context.

If I debug directly in the browser, it shows the local context as it should. Is this a known issue? Maybe there is a problem with the mappings between the JS file and the TS file?

I am using VS2013 Update 4 and TypeScript 1.4.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 6, 2015

The problem is the debugger does not know about typescript, all it knows is javascript and a source map. the source map file just lists the mappings for statements from source(.ts) to target (.js), but does not track renamed variables (e.g. _this).

We are aware of this issue, and it has been a long standing one. the issue is more pressing now as we are doing more of these rewrites with let, const, destructuring and computed properties changes.

@mhegazy mhegazy added the Bug A bug in TypeScript label Apr 6, 2015
@mhegazy mhegazy added Suggestion An idea for TypeScript and removed Bug A bug in TypeScript labels Apr 22, 2015
@danmoseley
Copy link
Member

When 2859 is fixed this should also "just work" in the IE developer tools, ie., it will hide the translation. However the wiring has not been done in Visual Studio at this time.

@mhegazy mhegazy added Visual Studio Integration with Visual Studio Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. labels Dec 9, 2015
@gynet
Copy link

gynet commented Jul 24, 2018

It's still an issue with vs code with es5 and arrow function, it's really annoying should be addressed with a higher priority.

@RyanCavanaugh
Copy link
Member

We've done all we can from the TS side (sourcemaps) -- this issue belongs in the respective debugger teams' repos now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript Visual Studio Integration with Visual Studio
Projects
None yet
Development

No branches or pull requests

5 participants