Menu
CoddyTech
Course

TypeScript for Lua Developers

Learn the JavaScript runtime and TypeScript contracts from Lua. Compare tables, truthiness, closures, missing values and module conventions, then build typed modules and a validated order-processing tool.

Lua and TypeScript side by side

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

  1. Run TypeScript

    Lua executes chunks and uses local bindings; standard Lua has no TypeScript-style static annotation syntax. TypeScript also erases types, but this course runner checks and compiles TypeScript before Node executes it. Braces replace Lua end-delimited blocks.…

    Lua
    1local name = "Ada"2print("Hello, " .. name .. "!")
    TypeScript
    1const name: string = "Ada";2console.log(`Hello, ${name}!`);
  2. Numbers and Conversion

    Lua 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…

    Lua
    1local value = assert(tonumber("12"))2print(value + 3)
    TypeScript
    1const value: number = Number("12");2console.log(value + 3);
  3. Arrays and Slice

    Lua 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…

    Lua
    1local values = {1, 2, 3, 4}2local middle = {}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

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

    Lua
    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 Lua 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 Lua sequence or JavaScript…

    Lua
    1local values = {}2print(not not values)
    TypeScript
    1const value: unknown = [];2console.log(Boolean(value));
  6. Annotations and Inference

    Lua 5.4 distinguishes integer and floating-point numeric subtypes; this multiplication uses a floating operand. TypeScript number uses JavaScript floating-point arithmetic for both whole and fractional values. BigInt is a separate runtime type outside these…

    Lua
    1local price, count = 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 Lua developers

Learn TypeScript from another language

Frequently asked questions

Who is TypeScript for Lua Developers for?

For people who already write Lua and want to learn TypeScript. Each lesson starts from Lua 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 Lua basics: variables, conditions, loops, functions and collections.

How many lessons does TypeScript for Lua Developers have?

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

What does TypeScript for Lua Developers cover?

The course is organized into chapters covering: Start Here, Runtime Values, Runtime Collections, Runtime Control Flow, and more.

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

Get started