Transplant.js ( or Tx.js
) is a strict syntactical superset of TypeScript.
It uses “types on the left”-style declarations and the classic C/C++/Java types like int, double, str and bool.
Tx.js files can be created with the .tx
extension.
You can read the Documentation here.
Tx.js uses the TypeScript compiler so make sure you have it installed aswell
# Locally in your project
$ npm install -D typescript
$ npm install -D transplant-js
# Or globally with TypeScript (Recommended)
$ npm install -g typescript
$ npm install -g transplant-js
After installation, you can use the Transplant.js compiler txc
To compile test.tx run
$ txc test.tx
This command will create a test.ts
and a test.js
file. You can do whatever you want with them! 🥳
- Transplant.js always tries to keep the same file name.
- Error handling is done by the TypeScript compiler, except input errors.
- Read the Docs
Write your code in Tx.js
// test.tx
int year = 2021;
const str fact = "Tx.js is awesome";
int[] myList = [ 3, 2, 1 ];
void myFunc(int y, str f) {
console.log(f + " in " + y);
}
The Tx compiler converts it to TypeScript
// test.ts
let year: number = 2021;
const fact: string = "Tx.js is awesome";
let myList: number[] = [ 3, 2, 1 ];
function myFunc(y: number, f: string): void {
console.log(f + " in " + y);
}
Then the TypeScript compiler does the dirty job to convert it to JavaScript
// test.js
let year = 2021;
const fact = "Tx.js is awesome";
let myList = [ 3, 2, 1 ];
function myFunc(y, f) {
console.log(f + " in " + y);
}
This project is licensed under the MIT license. For more information, see the LICENSE file.