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
As a library consumer, I would like to be able to call an API method which takes a file location and a TS string and returns a JS string.
And by that I mean a function which given an execution context and a TS string, gives equivalent JS for that location (like transpile, but context aware).
This is useful for watch expressions and console debugging, and without something like this, it is difficult/impossible to account for all the renaming the TS compiler does in such expressions (super, this, arguments, default parameters, probably more).
Could someone reasonably write this with a wrapper using transpile and source maps? It's likely we'd have to do almost the entire amount of work as the entire file anyway, so the perf impact of running the whole file seems minimal.
@RyanCavanaugh Not... really? Certainly not easily. AFAIK it's relatively impossible to just text-edit expressions directly into some contexts (like if I wanted to execute an expression in the context of a parameter initializer). TBH what needs to happen is, once transforms is merged, calculate the transforms flags up to the desired execution context, then create a node tree for the input expression and transform it using those node flags and the active compiler options. (This is what @rbuckton had told me back when I has first asked for the feature.)
As a library consumer, I would like to be able to call an API method which takes a file location and a TS string and returns a JS string.
And by that I mean a function which given an execution context and a TS string, gives equivalent JS for that location (like transpile, but context aware).
This is useful for watch expressions and console debugging, and without something like this, it is difficult/impossible to account for all the renaming the TS compiler does in such expressions (
super
,this
,arguments
, default parameters, probably more).So, an example.
With project file
foo.ts
:calling
should yield the string
'_super.prototype.foo.call(this);'
The text was updated successfully, but these errors were encountered: