This is almost identical how the above mentioned java2ts script does it, except for some support code to transform the config json file into the require configuration structure. Define a script in your package.json:Ĭonst configuration: IConverterConfiguration = const converter = new JavaToTypescriptConverter ( configuration ) await converter. When you install the tool locally in a project, you can use an NPM script to run it. The other way is to write an own script which imports the necessary classes and run the process from there.
For convenience there's a converter script, exported as binary script when adding the converter package as dependency, which can be executed. There are two ways to execute a conversion. Install the tool like most other Node.js packages, by running npm i java2typescript in your project folder. The converter uses (a copy of) the Java grammar from the ANTLR4 grammar directory, which supports Java 17, however, only language features up to Java 11 are supported. The conversion usually takes a Java source package (path to the package root) and creates a copy of the folder structure of that, thereby translating all *.java files to Typescript. This tool is a Node.js application written in Typescript to convert Java source code to Typescript.