Skip to content

TypeScript.Clearer flow.

Twill extends TypeScript with Swift-inspired syntax. Add guards, defer, trailing closures and checked switch expressions; keep TypeScript's types and compile to ordinary JavaScript.

TypeScript types · No language runtime · Experimental 0.1

workflow.twill.twill → TypeScript
twill
async function readOwned(acquire) {
  const resource = await acquire();
  defer {
    await resource.close();
  }

  guard const name = await resource.read() else {
    return 'Missing';
  }
  return name.toUpperCase();
}
Validate early. Release on every exit.

No language runtime

Native arrows, branches and framework APIs.

Your TypeScript types

Inference, narrowing and checked union cases.

One file at a time

Keep TS/JS imports and your existing build.

See what changes.

Small changes to the code you read every day.

TypeScript

ts
const user = findUser(id);
if (user == null) {
  return 'Missing';
}
return user.name;

Twill

twill
guard const user = findUser(id) else {
  return 'Missing';
}
return user.name;

Keep the successful path in view.

An explicit exit narrows the value for the rest of the scope. Nullish checks keep zero and false.

Read the semantics and tradeoffs

A language is only useful
with its tools.

Write, check, format and debug in one working loop.

Editor
Completion, diagnostics, rename and source debugging.
Quality
TypeScript checking, Prettier and ESLint.
Delivery
Vite, Node ESM, source maps and native declarations.
Explore the toolchain

Start small.
Keep your options open.

Use Twill where clearer control flow earns its place. Keep the rest of your project in TypeScript.

  1. 01Try a workflow
  2. 02Add one module
  3. 03Check it in CI