项目作者: ASDAlexander77

项目描述 :
The TypeScriptLUA repo contains the complete source code implementation for TypeScript compiler for LUA bytecode
高级语言: TypeScript
项目地址: git://github.com/ASDAlexander77/TypeScriptLua.git
创建时间: 2018-08-16T13:11:37Z
项目社区:https://github.com/ASDAlexander77/TypeScriptLua

开源协议:

下载


TypeScript for Lua

The TypeScriptLua repo contains the complete source code implementation for TypeScript compiler for Lua bytecode.

Chat Room

Want to chat with other members of the TypeScript for Lua community?

Join the chat at https://gitter.im/ASDAlexander77/cs2cpp

Engage, Contribute and Provide Feedback

Some of the best ways to contribute are to try things out, file bugs, and join in design conversations.

License

TypeScriptLua is licensed under the MIT license.

Quick Start

Prerequisite: nodejs, Lua 5.3, VSCode

1) Build Project

  1. npm install
  2. npm run build

2) Compile test.ts

create file test.ts

  1. declare var print: any;
  2. class Person {
  3. protected name: string;
  4. constructor(name: string) { this.name = name; }
  5. }
  6. class Employee extends Person {
  7. private department: string;
  8. constructor(name: string, department: string) {
  9. super(name);
  10. this.department = department;
  11. }
  12. public get ElevatorPitch() {
  13. return `Hello, my name is ${this.name} and I work in ${this.department}.`;
  14. }
  15. }
  16. let howard = new Employee("Howard", "Sales");
  17. print(howard.ElevatorPitch);
  1. node __out/main.js test.ts

Now you have test.lua

3) Run it.

  1. lua test.lua

Result:

  1. Hello, my name is Howard and I work in Sales.

Enjoy it.

How to use JavaScript Library

1) Compile JavaScript Library

  1. cd experiments\jslib
  2. node ../../__out/main.js -singleModule

2) Copy JS.lua into your folder where you run the compiled app.

3) Compile test.ts

create file test.ts

  1. class Person {
  2. protected name: string;
  3. constructor(name: string) { this.name = name; }
  4. }
  5. class Employee extends Person {
  6. private department: string;
  7. constructor(name: string, department: string) {
  8. super(name);
  9. this.department = department;
  10. }
  11. public get ElevatorPitch() {
  12. return `Hello, my name is ${this.name} and I work in ${this.department}.`;
  13. }
  14. }
  15. let howard = new Employee("Howard", "Sales");
  16. console.log(howard.ElevatorPitch);
  1. node __out/main.js test.ts

4) Run it.

  1. lua -e "require('./JS')" test.lua

Result:

  1. Hello, my name is Howard and I work in Sales.

Enjoy it