Skip to content

Language guide ​

ThicketScript will feel familiar if you know TypeScript. Classes, interfaces, generics, arrow functions, async and await all look the way you expect. Underneath it is its own language, with its own type system, a bytecode compiler and a virtual machine. A few things are deliberately different, and this guide points them out as it goes.

ts
enum Team {
    Red,
    Blue,
}

class Player {
    constructor(public name: string, public team: Team, public hp: int = 100) {}

    isAlive(): boolean {
        return this.hp > 0;
    }
}

const players: Array<Player> = [
    new Player("Ada", Team.Red),
    new Player("Brin", Team.Blue, 0),
];

for (const p of players) {
    const status: string = p.isAlive() ? "alive" : "down";
    console.log(`${p.name}: ${status}`);
}

The pages ​

PageWhat it covers
Typesint, uint, float, string, boolean, unions, null, arrays, maps, is and as.
Variableslet, const, scope and assignment.
FunctionsDeclarations, arrow functions, default and rest parameters, closures.
ClassesFields, constructors, inheritance, access modifiers, getters, abstract and final.
InterfacesShapes, implements, optional members.
EnumsNamed constants, bitflags, switch strict.
GenericsType parameters on functions, classes and interfaces.
Control flowif, loops, ranges, switch, labels.
Async, series and parallelPromises, await, and the series and parallel blocks.
Errorsthrow, try, typed catch, inline try, defer.
Modules and importsimport, export, system modules and path aliases.
Coming from TypeScriptWhat is left out, what is accepted and ignored, and what works differently.

The house style ​

Every sample on this site follows the same rules, and the checker nudges you toward them too:

  • Explicit types everywhere. let count: int = 0;, not let count = 0;. Functions declare their return type, even void.
  • Semicolons at the end of every statement.
  • int, uint and float, never number. There is no number type.
  • boolean, never bool.
  • for (const x of items) to loop over a collection.
  • Parentheses around every if, for, while and switch condition.

Feature checklist at a glance ​

Everything on this list runs on the current thicket.

Language

  • Classes, interfaces, generics, enums (numeric, string and bitflag) and switch strict.
  • struct value types with methods and operator overloads.
  • Packed numbers in struct fields: int8, int16, int32, uint8, uint16, uint32, float32.
  • Integer overflow and out-of-range stores raise a RangeError.
  • Ranges: for (const i of 0..<3) (or in) counts 0, 1, 2, and 0..<3 on its own is the array [0, 1, 2].
  • defer for cleanup on any scope exit, typed catch, and inline try expressions.
  • dump() prints values with their variable names.

Async and threads

  • async and await with Promises.
  • series and parallel, as function modifiers or blocks.
  • async worker functions: real threads, each in an isolated VM.
  • async mutex functions with per-key locks.

Standard library

  • 41 easing curves through Ease.apply, plus Math.lerp, moveTowards, snap, wrap and smoothstep.
  • Seeded Random: the same seed gives the same rolls.
  • Collection extras: unique, compact, sum, avg and first on arrays; union and intersection on Set.
  • Reactive state: Ref, computed and Signal from the reactivity module.
  • Databases: SQLite everywhere. Linux release builds add MySQL/MariaDB, Postgres and Redis. Packaged window builds carry SQLite only.

Safety

  • A sandbox by default: file, network, crypto, database, shell, environment and audio access stay off until thicket.json grants them.
  • A stack overflow is a catchable RangeError, not a crash.

Tooling, all in thicket

  • run, watch, check, fmt, debug, compile, build, new, tool, lsp and mcp. mcp runs a Model Context Protocol server. Use --project <dir> when a client starts it outside the project folder.
  • Debugging over the Debug Adapter Protocol for your IDE, or Chrome DevTools.

Coming from TypeScript ​

The differences that trip people up most. The Coming from TypeScript page has the full list.

TypeScriptThicketScript
numberint, uint or float
7 / 2 is 3.57 / 2 is 3 when both sides are int
== coerces== and === are both strict
Structural typingNominal: a class must say implements to count as the interface
Integer overflow is silentInteger overflow raises a RangeError
Promise.allAlso parallel { ... }