Skip to content

Coming from TypeScript

If you write TypeScript, you already reach for most of Bynk’s ideas — you just assemble them by hand, by convention, and with libraries. Bynk’s bet is that the patterns you reach for should be the language. This page is a quick translation table: the thing you hand-roll in TypeScript, and the Bynk construct that does it for you.

It is an orientation, not a tutorial — for the hands-on build, start with Tutorial 1; for the deeper whether and when to choose Bynk, see Bynk compared to TypeScript.

In TypeScript you…In Bynk…Note
hand-roll a branded type — type OrderId = string & { readonly __brand: "OrderId" }declare an opaque typetype OrderId = opaque Stringthe brand is the language’s job; see opaque types
validate at the edge with zod or manual if checksgive the type a refinement and construct with .of (which returns a Result)validation happens once, at the boundary — refined types
cast with as to assert validityuse .unsafe (the explicit escape hatch), or write a literal and let admission check it at compile timethe cast is named and searchable — admission
return Result/Either by convention (neverthrow, fp-ts)get Result[T, E] in the languagethe caller must handle Err to reach T
throw exceptionsreturn errors as values; propagate with ?no hidden control flow — type-system philosophy
guard null / undefineduse Option[T] (Some / None)absence is in the type, where the compiler can see it
a discriminated union + switch with no defaulta sum type read with an exhaustive matchthe compiler checks every variant is handled
an interface of fieldsa recordtype system
wire dependencies by hand or with decoratorsdeclare a capability, ask for it with given, and supply a providerdependencies are explicit and checked — capabilities
write a Worker fetch handler and a routerwrite an from http service and let Bynk emit the WorkerHTTP
hand-write a Durable Object classdeclare an agent — a key and store fields, written with := and committed atomically when the handler returnsthe agent model

Two themes run through the table. First, things you assert by convention become things the compiler checks: a brand, a validated value, an exhaustive switch, a declared dependency. Second, structure you express in folders and framework glue becomes part of the language: a context is a boundary, a service groups handlers, an agent owns state. You write less plumbing, and the compiler can hold you to the shape you intended.

The cost side of that trade — a new toolchain, a smaller ecosystem — is discussed honestly in Bynk compared to TypeScript.

  • Build something: Tutorial 1 is a five-minute warm-up; tutorials 2–6 then build one real service end to end.
  • Keep the glossary open for any unfamiliar term.
  • Skim the type-system philosophy for the reasoning behind the table.