Skip to content
Typescript to C compiler (TSCC)
C TypeScript CMake Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
typescript
.gitignore
CMakeLists.txt
LICENSE.md
Makefile
README.md
build_vs2017.bat

README.md

tscc

Typescript to C compiler

Support

The compiler currently supports:

  • Function definitions
  • Data types (string, number, null, void, undefined)
  • Arrays (sort of)
  • Function calls
  • If
  • Else
  • While loops
  • Static string concatenation ("hello " + "world")
  • Automatically detect requirements and inject #include tags
  • == - comparison
  • != - comparison
  • < - comparison
  • > - comparison
  • Null values
  • Undefined values
  • Classes with methods
  • Classes with member variables
  • console.log

Installation & Usage

To install tscc, first simply compile it:

    make

Then you can move it to /usr/local/bin:

    sudo mv ./tscc.out /usr/local/bin/tscc

Now you can use it like this:

    tscc <filename>.ts

Known issues

For loops

For loops does not work:

    for (let entry of someArray) {
        console.log(entry); // 1, "string", false
    }

Comments

Comments does not work:

    // this is a comment

    /* this is also a comment */

Floating point numbers

Floating point numbers are malformed when compiled, the following code:

    let age:number = 33.5;

Becomes this when compiled (int):

    int age = 33.5f;

Interfaces

Interfaces are currently not supported

    interface LabeledValue {
        label: string;
        value: number;
    }

Exports & Imports

Exports and imports are currently not supported:

    export * from "./ZipCodeValidator";  // exports class 'ZipCodeValidator

    ...

    import { ZipCodeValidator } from "./ZipCodeValidator";

Too many semi colons

The output basically looks like this right now:

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Solutions

If you find any solution for any of these issues, feel free to create a pull-request... Also if you find any other issues, please report them.

Notes

Machine code

The compiler does not turn the typescript input to machine code, you should use a C compiler to do that. I would suggest using gcc.

You can’t perform that action at this time.