The TypeScriptLua repo contains the complete source code implementation for TypeScript compiler for Lua bytecode.
Want to chat with other members of the TypeScript for Lua community?
Some of the best ways to contribute are to try things out, file bugs, and join in design conversations.
TypeScriptLua is licensed under the MIT license.
Prerequisite: nodejs, Lua 5.3, VSCode
- Build Project
npm install
npm run build
- Compile test.ts
create file test.ts
declarevarprint: any;classPerson{protectedname: string;constructor(name: string){this.name=name;}}classEmployeeextendsPerson{privatedepartment: string;constructor(name: string,department: string){super(name);this.department=department;}publicgetElevatorPitch(){return`Hello, my name is ${this.name} and I work in ${this.department}.`;}}lethoward=newEmployee("Howard","Sales");print(howard.ElevatorPitch);node __out/src/main.js test.ts
Now you have test.lua
- Run it.
lua test.lua
Result:
Hello, my name is Howard and I work in Sales.
Enjoy it.
- Compile JavaScript Library
cd experiments\jslib
node ../../__out/src/main.js -singleModule
Copy JS.lua into your folder where you run the compiled app.
Compile test.ts
create file test.ts
classPerson{protectedname: string;constructor(name: string){this.name=name;}}classEmployeeextendsPerson{privatedepartment: string;constructor(name: string,department: string){super(name);this.department=department;}publicgetElevatorPitch(){return`Hello, my name is ${this.name} and I work in ${this.department}.`;}}lethoward=newEmployee("Howard","Sales");console.log(howard.ElevatorPitch);node __out/src/main.js test.ts
- Run it.
lua -e "require('./JS')" test.lua
Result:
Hello, my name is Howard and I work in Sales.
Enjoy it
First working example in folder experiments/BABYLON (from Babylong.js)
