Giter Site home page Giter Site logo

zeta1999 / typescripttolua Goto Github PK

View Code? Open in Web Editor NEW

This project forked from typescripttolua/typescripttolua

0.0 0.0 0.0 3.87 MB

Typescript to lua transpiler. https://typescripttolua.github.io/

License: MIT License

TypeScript 98.51% Lua 0.44% JavaScript 1.05%

typescripttolua's Introduction

TypeScriptToLua

TypeScriptToLua

Continuous Integration status Coverage Chat with us!

A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!

Large projects written in lua can become hard to maintain and make it easy to make mistakes. Writing code in TypeScript instead improves maintainability, readability and robustness, with the added bonus of good IDE support. This project is useful in any environment where Lua code is accepted, with the powerful option of simply declaring any existing API using TypeScript declaration files.

Documentation

More detailed documentation and info on writing declarations can be found on the wiki.

Changelog can be found in CHANGELOG.md

Usage Guide

Install

npm install -g typescript-to-lua

Compile Files

tstl path/to/file.ts path/to/other-file.ts

Compile Projects

tstl -p path/to/tsconfig.json

Compile project in watch mode

tstl -p path/to/tsconfig.json --watch

Example tsconfig.json

{
  "compilerOptions": {
    "target": "esnext",
    "lib": ["esnext"],
    "strict": true
  },
  "tstl": {
    "luaTarget": "JIT"
  }
}

Contributing

All contributions are welcome, but please read our contribution guidelines!

Declarations

The real power of this transpiler is usage together with good declarations for the Lua API provided. Some examples of Lua interface declarations can be found here:

Sublime Text integration

This compiler works great in combination with the Sublime Text Typescript plugin (available through the package manager as TypeScript).

You can simply open your typescript project assuming a valid tsconfig.json file is present. The default TypeScript plugin will provide all functionality of a regular TypeScript project.

Setting up a custom build system

To add the option to build with the Lua transpiler instead of the regular typescript compiler, go to Tools > Build System > New Build System.... In the new sublime-build file that opens, enter the following (adjust path to tstl if not installed globally):

{
    "cmd": ["tstl", "-p", "$file"],
    "shell": true
}

Save this in your Sublime settings as a TypeScriptToLua.sublime-build. You can now select the TypeScriptToLua build system in Tools > Build System to build using the normal hotkey (ctrl+B), or if you have multiple TypeScript projects open, you can choose your compiler before building by pressing ctrl+shift+B.

typescripttolua's People

Contributors

ark120202 avatar brianhang avatar dmarcuse avatar doctorgester avatar dustinlacewell avatar ehntae avatar endel avatar gakada avatar hazzard993 avatar infiniterain avatar janne252 avatar lightrabbit avatar lolleko avatar martinjlowm avatar nucleartide avatar perryvw avatar radekmie avatar thatcosmonaut avatar thelartians avatar tomblind avatar wouterz90 avatar yancouto avatar zapp-brannigan-dota avatar zengjie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.