Menu
CoddyTech
Course

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.

  1. 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…

    Luau
    1local name: string = "Ada"2print("Hello, " .. name .. "!")
    TypeScript
    1const name: string = "Ada";2console.log(`Hello, ${name}!`);
  2. 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…

    Luau
    1local value = assert(tonumber("12"))2print(value + 3)
    TypeScript
    1const value: number = Number("12");2console.log(value + 3);
  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…

    Luau
    1local values: {number} = {1, 2, 3, 4}2local middle: {number} = {}3for i = 2, #values - 1 do middle[#middle + 1] = values[i] end4print("[" .. table.concat(middle, ",") .. "]")
    TypeScript
    1const values: number[] = [1, 2, 3, 4];2console.log(JSON.stringify(values.slice(1, -1)));
  4. 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.…

    Luau
    1local total = 02for _, value in ipairs({3, -1, 2}) do3    if value > 0 then total = total + value end4end5print(total)
    TypeScript
    1let total: number = 0;2for (const value of [3, -1, 2]) { if (value > 0) total += value; }3console.log(total);
  5. 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…

    Luau
    1local values = {}2print(not not values)
    TypeScript
    1const value: unknown = [];2console.log(Boolean(value));
  6. 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…

    Luau
    1local price: number, count: number = 2.5, 42print(string.format("%g", price * count))
    TypeScript
    1const price: number = 2.5;2const count = 4;3console.log(price * count);

Syllabus

12 chapters48 lessons1 project48 challenges96 quiz questions

Start Here

1 lesson

Final Challenges

2 lessons

More courses for Luau developers

Learn TypeScript from another language

Frequently 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.

Coddy programming languages illustration

Start TypeScript for Luau Developers for free

Get started