Run TypeScript Compiler with Java

I am trying to run the TypeScript compiler from my Java application. To start, I'm trying to figure out if I can run the compiler from the command line without Node.js:

$ jsc tsc.js 

But in this way I do not get any errors and do not help.

 $ jsc tsc.js myscript.ts 

It will not give anything.

It's easy to run js code directly from java (and I hope to run this compiler this way), but is it possible to run the TypeScript compiler without Node.js?

EDIT:

I confirm the same behavior with a rhino.

+4
source share
3 answers

Looking at the source code, the tsc command invokes the JS script tsc.js , which has 2 backend: Node.js and Windows Scripting Host. If any other JavaScript server supports reading and writing to the file system (for example, Rhino with RingoJS), it should be able to run the TypeScript tsc.js compiler.

In addition, there is a TypeScript compiler fork that claims to work on Rhino . This way you can call Rhino directly from Java without installing Node.js.

+3
source

I have a Typescript4j project that does just that.

It runs the Typescript compiler wrapped in Rhino.

I successfully use it in Bakehouse and a non-trivial Typescript application.

+5
source

The TypeScript compiler is implemented in TypeScript and can be used on any JavaScript node.

You may need to specify the full path to tsc.js

-1
source

Source: https://habr.com/ru/post/1443933/


All Articles