A TypeScript-to-Lua Compiler for Roblox
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
include Add TS.import to easily support Instance.WaitForChild calls Oct 17, 2018
src Merge branch 'master' into feature/waitImport Oct 17, 2018
.editorconfig initial commit 🎉 Sep 5, 2018
.gitattributes initial commit 🎉 Sep 5, 2018
.gitignore add .vscode to .gitignore Sep 12, 2018
.luacheckrc initial commit 🎉 Sep 5, 2018
.prettierrc.json initial commit 🎉 Sep 5, 2018
LICENSE.md update LICENSE.md Sep 17, 2018
README.md fix typo in README.md Oct 17, 2018
package-lock.json npm update Oct 9, 2018
package.json
tsconfig.json update tsconfig.json Sep 14, 2018
tslint.json update tslint.json Oct 4, 2018

README.md

roblox-ts

A TypeScript-to-Lua Compiler for Roblox
 

Why?

As Roblox games become increasingly complex and larger in size, writing safe code becomes challenging with Lua. In addition, Lua is difficult to make tooling for. Roblox Studio attempts to provide things like intellisense and autocomplete, but it's mostly just guessing.

roblox-ts attempts to solve this problem by compiling TypeScript code into (Roblox flavored) Lua code.

Documentation

⚠️ Documentation is a work in progress. ⚠️

https://roblox-ts.github.io/

Getting Started

Installation & Usage

In order to start using roblox-ts, you'll need to have NodeJS and npm installed. You can download both from here.

Next, from your command line install roblox-ts: npm install -g roblox-ts
(UNIX systems may need you to prefix this command with sudo)

You can now run roblox-ts with the command rbxtsc.

Usage: rbxtsc [options]

Options:
  -w, --watch        enable watch mode                                 [boolean]
  -p, --project      project path                                 [default: "."]
  -i, --includePath  folder to copy runtime .lua files to   [default: "include"]
  --noInclude        do not copy runtime .lua files             [default: false]
  -v, --version      show version information                          [boolean]
  -h, --help         show help                                         [boolean]

Project Folder Setup

We recommmend that you write your TypeScript in VS Code for the best experience. However, also editors like Sublime Text and Atom are supported.

  1. Create a new folder and name it whatever you'd like. For example: MyCoolProject

  2. Run npm init -y inside of your folder. This will create your package.json file.

  3. Create a folder called src to contain your TypeScript files.

  4. Create a file named tsconfig.json in your project folder. The contents should look like this:

{
	"compilerOptions": {
		"outDir": "out",
		"rootDir": "src",
		"baseUrl": "src",
		"module": "commonjs",
		"strict": true,
		"noLib": true,
		"downlevelIteration": true,
		"declaration": false,
		"target": "es6"
	},
	"typeAcquisition": {
		"enable": true
	}
}

(warning: do not change these values unless you know what you are doing!)

  1. Create a file for syncing your compiled .lua files to Roblox Studio. If you're using Rojo, this should be a rojo.json file and look like:
{
	"partitions": {
		"include": {
			"path": "include",
			"target": "ReplicatedStorage.RobloxTS.Include"
		},
		"modules": {
			"path": "modules",
			"target": "ReplicatedStorage.RobloxTS.Modules"
		}
	}
}

You should add more partitions for the subfolders of your out folder.

  1. Run npm install rbx-types to install the Roblox API type definitions.

  2. Start roblox-ts in watch mode rbxtsc -w

  3. Run your sync program. If you're using Rojo, this is rojo serve

  4. Write code!

Join the Community!

https://discord.gg/f6Rn6RY

Credits

roblox-ts is powered by ts-simple-ast and is inspired by TypescriptToLua