Skip to catalogue

11

types as spec

Write the data shape as types first, and let the compiler shout at the model.

What is types as spec?

Types are a machine-readable spec: fields, unions, impossible states. If the types fail, the implementation is not done.

Why does types as spec matter when vibe coding?

Models write JavaScript eagerly, and invent fields. Locking types first is a free “did you make something up” check every turn. Cheaper than scanning the diff by eye.

How do you do types as spec?

Commit the types first. Ban `any` as an escape. Run tsc. Fix from the errors. Do not edit the types to soothe a wrong implementation.

How do you ask a model for types as spec?

Types first, no logic. Fields for (object) are as follows. No `any`. Not done until tsc is clean. Do not widen types to make a bad implementation compile.

What goes wrong with types as spec?

Everything is `string` and optional. That is an empty spec. Encode impossible states as unions, or the types have no teeth.

adjacent