Skip to content

Your first script ​

One file ​

Save this as hello.tks:

ts
const name: string = "world";
console.log("Hello, " + name + "!");

Run it:

sh
thicket run hello.tks
text
Hello, world!

A .tks file runs from top to bottom. You do not need a project file for a quick script.

Two things to notice already:

  • Every declaration has a type. const name: string, not const name. The checker warns when a type is missing.
  • Every statement ends with a semicolon.

A little more ​

Template strings, typed arrays and loops all look the way you expect:

ts
const name: string = "ThicketScript";
const version: int = 1;

console.log(`Hello from ${name} v${version}!`);

const items: Array<string> = ["fast startup", "typed numbers", "batteries included"];
for (const item of items) {
    console.log(`  - ${item}`);
}
text
Hello from ThicketScript v1!
  - fast startup
  - typed numbers
  - batteries included

A project ​

Real programs live in a project: a folder with a thicket.json (or thicket.json5) file. Make one with thicket new:

sh
thicket new hello
cd hello
thicket run

thicket new writes three files:

text
hello/
  .gitignore
  app.tks
  thicket.json5

The project file names the entry file:

json5
{
  "entry": "app.tks"
}

And app.tks holds a class with a static main() method:

ts
class ConsoleApp {
    static main(): void {
        console.log("hello from thicket");
    }
}

When the entry file declares a class with static main(), thicket run runs the file's top-level code first, then calls that main. A plain function main() at the top level is ordinary code and is never called for you.

main can also take the command-line arguments and return an exit code:

ts
class App {
    static main(args: Array<string>): int {
        console.log("started with " + args.length + " arguments");
        return 0;
    }
}

Pass arguments after --:

sh
thicket run -- --verbose --level=3

Templates ​

thicket new <name> <template> picks a starting point:

TemplateWhat you get
consoleA console app (the default).
windowA window app.
willowA console app that uses the willow 2D module.

Run it again on every save ​

sh
thicket watch

watch runs the program, then runs it again from scratch whenever a .tks file or thicket.json in the project changes.

Next: your first window.