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
| Page | What it covers |
|---|---|
| Types | int, uint, float, string, boolean, unions, null, arrays, maps, is and as. |
| Variables | let, const, scope and assignment. |
| Functions | Declarations, arrow functions, default and rest parameters, closures. |
| Classes | Fields, constructors, inheritance, access modifiers, getters, abstract and final. |
| Interfaces | Shapes, implements, optional members. |
| Enums | Named constants, bitflags, switch strict. |
| Generics | Type parameters on functions, classes and interfaces. |
| Control flow | if, loops, ranges, switch, labels. |
| Async, series and parallel | Promises, await, and the series and parallel blocks. |
| Errors | throw, try, typed catch, inline try, defer. |
| Modules and imports | import, export, system modules and path aliases. |
| Coming from TypeScript | What 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;, notlet count = 0;. Functions declare their return type, evenvoid. - Semicolons at the end of every statement.
int,uintandfloat, nevernumber. There is nonumbertype.boolean, neverbool.for (const x of items)to loop over a collection.- Parentheses around every
if,for,whileandswitchcondition.
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. structvalue 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)(orin) counts 0, 1, 2, and0..<3on its own is the array[0, 1, 2]. deferfor cleanup on any scope exit, typedcatch, and inlinetryexpressions.dump()prints values with their variable names.
Async and threads
asyncandawaitwith Promises.seriesandparallel, as function modifiers or blocks.async workerfunctions: real threads, each in an isolated VM.async mutexfunctions with per-key locks.
Standard library
- 41 easing curves through
Ease.apply, plusMath.lerp,moveTowards,snap,wrapandsmoothstep. - Seeded
Random: the same seed gives the same rolls. - Collection extras:
unique,compact,sum,avgandfirston arrays;unionandintersectiononSet. - Reactive state:
Ref,computedandSignalfrom thereactivitymodule. - 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.jsongrants them. - A stack overflow is a catchable
RangeError, not a crash.
Tooling, all in thicket
run,watch,check,fmt,debug,compile,build,new,tool,lspandmcp.mcpruns 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.
| TypeScript | ThicketScript |
|---|---|
number | int, uint or float |
7 / 2 is 3.5 | 7 / 2 is 3 when both sides are int |
== coerces | == and === are both strict |
| Structural typing | Nominal: a class must say implements to count as the interface |
| Integer overflow is silent | Integer overflow raises a RangeError |
Promise.all | Also parallel { ... } |