TypeScript for Luau Developers
Learn the JavaScript runtime and TypeScript contracts from Luau. Compare table types, tagged unions, generics, callbacks and runtime behavior, then build typed modules and a validated order-processing tool.
Luau and TypeScript side by side
The same program in Luau and in TypeScript, from the lessons of this course.
Run TypeScript
Luau supports optional static annotations and compiles scripts to its own VM bytecode; these types do not convert values at runtime. TypeScript also erases types, but this course runner checks and compiles TypeScript before Node executes it. Braces replace…
Luau1local name: string = "Ada"2print("Hello, " .. name .. "!")TypeScript1const name: string = "Ada";2console.log(`Hello, ${name}!`);Numbers and Conversion
Luau tonumber returns nil when conversion fails; callers must check before arithmetic. JavaScript Number returns NaN instead, and unexpectedly converts blank text to zero. Validate blankness and finiteness explicitly. A TypeScript annotation does not perform…
Luau1local value = assert(tonumber("12"))2print(value + 3)TypeScript1const value: number = Number("12");2console.log(value + 3);Arrays and Slice
Luau dense sequences conventionally start at index one, and a loop can copy their middle entries. Negative table keys are independent keys rather than end offsets. JavaScript arrays start at zero; slice creates a shallow range copy. Use at(-1) or an explicit…
Luau1local values: {number} = {1, 2, 3, 4}2local middle: {number} = {}3for i = 2, #values - 1 do middle[#middle + 1] = values[i] end4print("[" .. table.concat(middle, ",") .. "]")TypeScript1const values: number[] = [1, 2, 3, 4];2console.log(JSON.stringify(values.slice(1, -1)));For-of and Array Values
Luau ipairs traverses consecutive integer keys starting at one and stops at the first missing entry. JavaScript for-of visits array values, while for-in enumerates keys. There is no built-in range syntax required here: for-of already supplies each element.…
Luau1local total = 02for _, value in ipairs({3, -1, 2}) do3 if value > 0 then total = total + value end4end5print(total)TypeScript1let total: number = 0;2for (const value of [3, -1, 2]) { if (value > 0) total += value; }3console.log(total);Truthiness Is Not Emptiness
In Luau only nil and false are falsy; even zero, empty text and empty tables are truthy. JavaScript also treats empty arrays as truthy, but zero and empty text are falsy. Test sequence length explicitly when asking whether a dense Luau sequence or JavaScript…
Luau1local values = {}2print(not not values)TypeScript1const value: unknown = [];2console.log(Boolean(value));Annotations and Inference
Luau has one number type based on double-precision floating point, rather than a separate integer numeric subtype. TypeScript number uses JavaScript floating-point arithmetic for both whole and fractional values. BigInt is a separate JavaScript runtime type…
Luau1local price: number, count: number = 2.5, 42print(string.format("%g", price * count))TypeScript1const price: number = 2.5;2const count = 4;3console.log(price * count);
Syllabus
12 chapters48 lessons1 project48 challenges96 quiz questionsStart Here
1 lessonRuntime Values
4 lessonsRuntime Collections
4 lessonsRuntime Control Flow
4 lessonsRuntime Edge Cases
4 lessonsTyped Contracts
5 lessonsTyped Flow
5 lessonsTyped Functions
5 lessonsTyped Collections
5 lessonsReliable Modules and Objects
5 lessonsProject: Typed Orders
4 lessonsFinal Challenges
2 lessonsFrequently asked questions
Who is TypeScript for Luau Developers for?
For people who already write Luau and want to learn TypeScript. Each lesson starts from Luau you know and shows how TypeScript does the same thing, so you skip the beginner basics.
Do I need to know TypeScript already?
No. The course starts with your first TypeScript program. You need Luau basics: variables, conditions, loops, functions and collections.
How many lessons does TypeScript for Luau Developers have?
TypeScript for Luau Developers contains 48 interactive lessons you can complete at your own pace.
What does TypeScript for Luau Developers cover?
The course is organized into chapters covering: Start Here, Runtime Values, Runtime Collections, Runtime Control Flow, and more.
Is TypeScript for Luau Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.