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


Does this have type information about what’s in the game tree? It would be useful to know the names and types of children of Workspace et al. Also if this information could be preserved for clone()'s, that would be really useful for things that use a lot of prefabs (i.e. GUIs).



Automatically, no. We do not take any data from Roblox Studio, so we cannot statically know the layout of your game.

In general, this is good. It makes your code more portable to not assume anything about the structure of a game.

But if you wanted this behavior, it’s pretty easy to hack it together like:

import { ReplicatedStorage } from "rbx-services";

type MyFramePrefab = Frame & {
	Child1: Frame & {
		Child2: Frame;

const frame = ReplicatedStorage.MyPrefabFrame.Clone() as MyFramePrefab;

const child2 = frame.Child1.Child2;

Using as you make an assertion to the compiler about the structure of the object.

This isn’t too different than Lua. It’s just more explicit. You’re making assertions of what you think the object is when you use properties/call methods in Lua.



Kinda sad that something like this isn’t already built-in to the platform. Yes, Lua is an easy-to-learn language. That doesn’t mean we can’t step it up a notch or two and add an alternative language.

Excellent work; will definitely use this.



Thank you for this. Will be very helpful.



Just merged in support for Roact with JSX thanks to a ton of work from @Vorlias.

Requires use of the rbx-roact package.




Huge update to our project website thanks to @evaera !
Works much better on mobile now.



Can you still override the index/newindex operators?



Yep, just not on class instances.

Regular objects work fine.

1 Like


We’ve cleaned up our documentation and moved it to the project site!

thanks to a ton of work by @evaera




Just published roblox-ts 0.0.23 and rbx-types 1.0.113
This is a breaking change and you’ll need to update existing code to make it work properly!

Going forward, creating Instances with the syntax new Part() will no longer work.
Instead, you should use new Instance("Part")
In addition, the instanceof operator will no longer work for data types (i.e. Vector3, UDim2, etc.) or for Instances.

To replace the functionality of instanceof, I’ve added a new built-in function:
typeIs(value: any, typeName: string): boolean
It’s equivalent to going typeof(value) == typeName, but allows for type narrowing in TypeScript.
For example:

// v is some unknown data
if (typeIs(v, "Vector3")) {
    print(v.X, v.Y, v.Z); // v is a Vector3

This works for any given type you might want to use with Roblox’s typeof() function: nil, boolean, number, string, table, Vector3, BrickColor3, Instance, etc.

If you wanted to know if a given value is a particular type of Instance, you could use typeIs in conjunction with .IsA():

if (typeIs(v, "Instance") && v.IsA("BasePart")) {
    print(v.Size); // v is a BasePart


Wow! This is definitely helpful with my future developments. Thanks!

1 Like


@Crazyman32 has a cool video showing this off if anyone is interested



I’ve been obsessed with this package, and I learned typescript so I could use it. However, when I initially tried this is was confusing due to all the compiler bugs and issues. When I can use my computer, I will try it out since I’m super excited to make a game using this. (I would imagine that most of the bugs would be fixed by summer.)

1 Like