"roblox-ts" - a TypeScript-to-Lua Compiler for Roblox

scripting

#1

I’d like to introduce roblox-ts, a TypeScript-to-Lua compiler for Roblox.

You can view our project website here

and our GitHub repository below:

image

image

Why?

This project was inspired by @zeuxcg’s “Scripting Next” Hackweek Project.

But this isn’t a new problem: In 2012, Microsoft attempted a similar solution to the same problem. JavaScript, a language that is widely used across the internet, suffers from the same problems that Lua does. Both languages share a lack of type safety which can cause type mismatch bugs to occur.

TypeScript is Microsoft’s solution to this problem. It is a programming language that compiles to JavaScript (mostly by stripping away type information) and does all of it’s type checking statically at compile time.

Type information allows the editor to infer things about the code you’re working with. It enables things like intellisense and type guarding. You can ensure that a given variable will always be a given type.

How?

roblox-ts is an attempt to bridge the abilities of TypeScript to work in a Roblox environment. We break down your code into an abstract syntax tree (aided by the TypeScript compiler) and emit functionally similar structures in Lua so that the code behaves the same (minus the type information).

If this sounds interesting, please check out our project website or join our Discord!


#2

oh man i am surely going to dig right into this. i loved when i scripted in unity and creating mobile games. and this can bring back those good old memories!


#3

Looks very interesting, i’m gonna give it a try. :grin:
Good job, looking forward for more stuff incoming.


#4

The Github repo’s readme file has a decent “quick start guide”
https://github.com/roblox-ts/roblox-ts#getting-started

Feel free to ask any questions in this thread or in the Discord.


#5

This is really cool, will definitely have to try it out


#6

give that here. gotta try it.


#7

I had the exact same idea about making a JS to Lua compiler a week ago too😅.
Thank you very much for this! Gotta try it👍


#8

Wow, this is truly amazing! Writing code is much cleaner & faster now. And I love the fact that we can do real Object-Oriented-Programming much easier now.

Just look at the TypeScript code it’s perfectly clear and easy to read (even for non-scripters) & write. Unlike the ugly Lua OOP way.

Keep up the good work!:+1::clap:


#9

Thanks for the feedback! If you run into any bugs please report them on GitHub or in our Discord.

We’re moving quickly with development to ensure this is a feasible tool for making games.


#10

I’ve created a wiki page that contains a list of useful npm packages you can use with roblox-ts!
Each package listed also has an example for how to use it.

The list will continue growing over time as more people create compatible packages.

https://github.com/roblox-ts/roblox-ts/wiki/Useful-Packages


#12

I love it. It would be cool if you did JS or C++ but again, I don’t know how converting between 2 language works. I would assume it’s not possible or very hard


#13

JavaScript has a lot of the same problems that Lua does when it comes to lack of type safety.
There’s a project called CASTL which transpiles JavaScript to Lua, however it struggles a bit with the + operator. For example, A + B, it’s unclear whether it should transpile that into A + B or A .. B since both strings and numbers use +.

TypeScript was chosen for this project because of how similar it is to Lua. Most features are fairly easily convertible to similarly functional structures in Lua.


#14

Thank you good sir for using the superior text editor, Atom


#15

I’d be curious to know why you prefer Atom over VS Code


#16

It looks like Atom, but it’s actually Visual Studio Code with Atom One Dark Theme


#17

I’ve been betrayed!


#18

For me it’s the UX of extensions/packages. I’ve used VSC but the UX of the ssh remote-edit extensions I’ve tried are just absolutely horrendous. All the ones I tried forced me to first create a directory for the server I was connecting to. I would rather not have to create directories manually. Additionally, the ones I tried seemed to not accept private key files (Why? I have no idea.) Personally, it really comes down to my overall work env. and my exp. with VSC


#19

We now have testing infrastructure setup thanks to help from @LouieK22

This will help ensure stability with new changes and validates that the existing code works as intended.

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


#20

Sublime is better than Atom and VS code. :stuck_out_tongue:

@Osyris Unfortunately I wasn’t aware of this project. I knew many Roblox employees wanted it, but didn’t know that work was started. We may be performing duplicate work (although we’re taking different routes). I’ve built a full GLR parser in Lua and am currently working on making a LuaWidget text editor in studio for it. I imagined users not only being able to use a typed version of Lua called Luafide, but also edit the syntax or semantic actions at any time or even easily make their own language.

The Github page is here
The model is here
And the proposed syntax changes are here

My goal is that all valid Lua is valid Luafide, that Luafide is as easy to use and install as possible, and to give advanced developers ultimate control of the language – by allowing them to modify it.

Wow, that really is unfortunate…


#21

That looks very cool. It looks like you’ve put a ton of hard work into it.

We decided to go with TypeScript because it already has extensive tooling available and matches up with Lua pretty well.

A Typed Lua would need extensions created for every popular editor for auto-completion, refactoring, syntax highlighting, etc.

But I’m happy to see more options available.