Typescript: Port from old compiler code to emit identifier renames into source map

Created on 22 Apr 2015  路  12Comments  路  Source: microsoft/TypeScript

The previous (1.0 or 1.1) compiler emitted a table of identifier renames into the source map. Principally this was for renames of "this" into "_this". The IE developer tools used this to make this scenario work

  • User is debugging Typescript in the IE tools -- Typescript was discovered by source map
  • User hovers over "this" at a point where Typescript had renamed it. In other words, in this context they expect to see the value of "_this" not "this".
  • The debugger looks up this source code location in a table in the source map to determine that at this point "this" was renamed and shows a tooltip for the value of "_this" instead. (It also put a red dot in the watches window)

This feature was lost when the compiler was rewritten because the table is no longer emitted into the source map. We'd like it back so that our feature works again..

Bug

Most helpful comment

+1

This bug is really annoying when debugging TypeScript code in Chrome (or any other browser). It would be great if this could be fixed soon! Thanks!

All 12 comments

this is related, and partially covers #2617

Bug, @mhegazy?

it is a bug alright.. the scope is bigger than your normal bug-level changes though.

+1

This bug is really annoying when debugging TypeScript code in Chrome (or any other browser). It would be great if this could be fixed soon! Thanks!

+1 in arrow functions ( () => {} ) 'this' is captured as Window making debugging almost impossible... this is the kind of bug that makes an interesant lenguage less atractive

+1 this needs to be addressed, makes debugging Cordova apps very confusing as well.

A fix would be much appreciated.

this is always undefined in browser dev tools. Easy to be perplexed.

One workaround for the lack of 'this' in the source map is to assign 'this' to another variable, such as 'self' and then use that variable (as a replacement for 'this') for the rest of the code in that function. In other words, "let self = this;"

Of course, this (or rather 'self') is a really annoying workaround because it needs to be applied to every function that you may wish to debug. I expect more from a modern development tool set.

Please fix!

I'm using Typescript 2.3.1 and seems to be fixed.

Proposal since it's been a while and browser support is better now: Target es2015 while debugging so the typescript compiler does need to translate the arrow functions into old es5. Then for production use es5 if one needs to.

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

Still an issue, would be good to get it addressed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kyasbal-1994 picture kyasbal-1994  路  3Comments

weswigham picture weswigham  路  3Comments

uber5001 picture uber5001  路  3Comments

wmaurer picture wmaurer  路  3Comments

Roam-Cooper picture Roam-Cooper  路  3Comments