Skip to content

Checking your code ​

sh
thicket check

check type-checks and compile-checks a program. Nothing runs and nothing is written. It prints ok when the program is clean. Otherwise it prints each diagnostic with its file, line, column and severity (error, warning or hint). It exits with code 1 when there is an error. Warnings and hints alone do not fail the check.

Like run, it takes a file, a project folder, or nothing (the nearest thicket.json above the current folder):

sh
thicket check
thicket check app.tks
thicket check ./mygame

What it catches ​

Save this as oops.tks:

ts
let score: int = "ten";
sh
thicket check oops.tks
text
oops.tks(1,5): error: Cannot assign "ten" to int (variable 'score')
oops.tks(1,5): hint PF012: variable 'score' is declared but never used

The checker also reports:

  • missing type annotations on variables and missing return types on functions (warning PF071),
  • unused variables (a hint),
  • calls with the wrong number or type of arguments,
  • members that a class or interface does not declare,
  • a class that says implements but leaves a member out,
  • await in the wrong place, and other async mistakes,
  • a switch strict that misses an enum member.

check also reports everything run would refuse at compile time, so a clean check means the program compiles.

Window apps are checked too ​

You can check a window app on a machine with no display. check never opens a window, so it is a good fit for a build server or a pre-commit hook.

In your editor ​

The JetBrains plugin runs the same checker through thicket lsp and underlines problems as you type.

Formatting ​

sh
thicket fmt app.tks
thicket fmt --check app.tks

fmt formats a file in place and keeps your comments. --check writes nothing and exits 1 when the file is not formatted.

Silencing one line ​

When a warning is wrong for one line, suppress it on the line before. The code in brackets limits it to one diagnostic:

ts
// @thicket-ignore-next-line [PF078]
const y: int = legacyRect.width;

Next: building a program.