tta small language for TypeScript and TSX

Language

try

Unwrap Ok or return Err from the nearest Result scope.

example.tt
import type { TResult } from "@tt/std";
import * as Result from "@tt/std/result";

function load(id: string): TResult<User, LoadError> {
const raw = try read(id);
const user = try decode(raw);
return Result.Ok(user);
}

Features

  • Value binding and propagate-only statements.
  • Value-form try works inside larger expressions, including return try f().
  • Different error paths infer as a union when the function is unannotated.
  • try await works for asynchronous Result-producing expressions.
Nextlet-else →