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:
class A {
foo(): string {
return 'A';
}
}
class B extends A {
foo(): string {
/*marker*/ return 'B';
}
}
calling
ts.transpileExpression(/*marker file location*/, 'super.foo()')
should yield the string
'_super.prototype.foo.call(this);'
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);'