Menu
CoddyTech
Course

Luau for TypeScript Developers

Transfer TypeScript skills to general Luau: truth rules, typed signatures, runtime validation, table collections, relative modules and metatable objects. Build a stock ledger and port two source programs.

TypeScript and Luau side by side

The same program in TypeScript and in Luau, from the lessons of this course.

  1. Print and Comment

    JavaScript uses + and template literals; Luau uses .. and backtick interpolation with braces instead of dollar-braces. console.log is a host API, while print is the Luau output function. TypeScript string annotations are erased; changing the annotation does…

    TypeScript
    1const greeting: string = "Hi" + ", Ada";2console.log(greeting);
    Luau
    1local name = "Ada"2print(`Hi, {name}`)
  2. Missing Fields and Optionals

    An own JavaScript property can exist with value undefined. Assigning nil removes a Luau table key. Port property-presence checks deliberately instead of translating undefined to a stored nil field. TypeScript optional properties describe possible absence. A…

    TypeScript
    1const record: {x?: number} = {x: undefined};2console.log("x" in record);
    Luau
    1local d = {x = nil}2print(d.x == nil)
  3. Inclusive Numeric Loops

    JavaScript for spells out initialization, condition and update. Luau numeric for includes its upper bound. Translate an exclusive JavaScript stop value to an inclusive Luau endpoint. Annotating the JavaScript loop counter does not alter its exclusive…

    TypeScript
    1let total: number = 0;2for (let i: number = 1; i < 4; i++) total += i;3console.log(total);
    Luau
    1local total = 02for i = 1, 3 do total = total + i end3print(total)
  4. Functions and Returns

    JavaScript functions accept omitted arguments as undefined; Luau receives nil. Both can pass functions as values. Luau additionally accepts erased signature annotations, but Run will not statically reject a wrong argument type. A TypeScript checker can reject…

    TypeScript
    1function twice(x: number): number { return x * 2; }2console.log(twice(4));
    Luau
    1local function twice(x: number): number return x * 2 end2print(twice(4))
  5. Lists as Dense Tables

    JavaScript arrays combine indexed storage, methods and a length property. Luau uses ordinary tables plus library operations. Keep sequence keys dense and do not copy zero-based array offsets. TypeScript array types do not repair sparse arrays introduced by…

    TypeScript
    1const a: string[]=["a","b","c"];2a.splice(1,1);3console.log(a.join(","));
    Luau
    1local a = {"a", "b", "c"}2table.remove(a, 2)3print(table.concat(a, ","))
  6. Sorting and Comparators

    JavaScript Array.sort comparators return a negative, zero or positive number. Luau table.sort comparators return booleans. Returning a numeric difference in Luau makes even zero truthy and breaks the ordering contract. A TypeScript comparator signature…

    TypeScript
    1const a: number[]=[3,1,2];2a.sort((x: number,y: number): number=>x-y);3console.log(a[0]);
    Luau
    1local a={3,1,2}2table.sort(a)3print(a[1])

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

Final Source Ports

2 lessons

More courses for TypeScript developers

Learn Luau from another language

Frequently asked questions

Who is Luau for TypeScript Developers for?

For people who already write TypeScript and want to learn Luau. Each lesson starts from TypeScript you know and shows how Luau does the same thing, so you skip the beginner basics.

Do I need to know Luau already?

No. The course starts with your first Luau program. You need TypeScript basics: variables, conditions, loops, functions and collections.

How many lessons does Luau for TypeScript Developers have?

Luau for TypeScript Developers contains 48 interactive lessons you can complete at your own pace.

What does Luau for TypeScript Developers cover?

The course is organized into chapters covering: First Luau Programs, Values and Decisions, Iteration and Flow, Functions and Closures, and more.

Is Luau for TypeScript 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 Luau for TypeScript Developers for free

Get started