-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Call Typescript Compiler from C# #2565
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
Comments
Someone else can do this. |
Um... I would have expected something like:
to work. But it doesn't. Guess that, "Someone else" has his work cut out for him. |
Not really. It's not entirely trivial, but it's decently easy to use Chakra/JsRT from C# with the following resource. You can check out the C# version of the sample app which is Apache 2.0 licensed. |
Also you can use Edge.js |
I did something like that here: https://github.com./DickvdBrink/TypeScriptSyntaxVisualizer/blob/master/TypeScriptSyntaxVisualizer/TypeScript/TypeScriptContext.cs |
OK, just to close the loop on this one, I got this working by removing the last line in tsc.js where is invokes the command line processling. I then created the following JS code:
and finally the C# code to invoke it:
I'm sure I missed a few things but there you have it. It of course relies on knowing something about the inner workings which means it will likely break in the next version. Maybe a method could be added in some future version that takes strings instead of files? |
I would highly recommend using the compiler API for these scenarios instead of just replacing strings in the compiler. here is how to use the compiler API: https://github.com./Microsoft/TypeScript/wiki/Using-the-Compiler-API And starting from next release, you should have a new API for string -> string transformation for modules, see issue #2499 for more details. |
Awesome. Just what I needed. |
Create nuget module to invokeTypescript compiler in C# to compile Typscript code specified in C# strings.
The text was updated successfully, but these errors were encountered: