Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Run TypeScript compiler from Java

Run TypeScript compiler from Java

Problem

I am trying to run the Typescript Compiler from my Java application. To start, I am trying to figure out, whether I can run the compiler from command-line without Node.js:

$ jsc tsc.js

But this way I don't get any errors, nor help.

$ jsc tsc.js myscript.ts

Will get me nowhere.

It is easy to run js code directly from java (and I am hoping to run the compiler in this way), but is it possible to run Typescript compiler without node.js?

EDIT:

I confirm the same behaviour with rhino.

Problem courtesy of: Vojtěch

Solution

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

Moreover, there is a fork of TypeScript compiler which claims to directly run on Rhino. So you could invoke Rhino directly from Java, without installing node.js.

Solution courtesy of: niutech

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Run TypeScript compiler from Java

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×