Skip to content
/ tx.js Public

Enable “types on the left”-style declarations and the 'classic' C/C++/Java types in Javascript.

License

Notifications You must be signed in to change notification settings

ati-n/tx.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is this ?

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.




Installation

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

How to run

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.

How it works

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);
    }

License

This project is licensed under the MIT license. For more information, see the LICENSE file.

About

Enable “types on the left”-style declarations and the 'classic' C/C++/Java types in Javascript.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published