Dev Helpers

TypeScript / Form handling

Track touched fields

Dev Helpers · July 7, 2026

A touched-field map tracks interaction separately from the underlying values. A field can be touched and still contain its original value.

Worked example

type Fields = { name: string; age: number; subscribed: boolean };
const initial: Fields = { name: "Ada", age: 30, subscribed: false };
console.log([...new Set<keyof Fields>(["name", "age"])]);

Result

[ 'name', 'age' ]

Implementation notes

A field can be dirty without being invalid. Store validation errors, touched state and current values according to the different questions they answer.

Try it yourself

Focus and blur a valid field without typing.

Open the TypeScript example →

Editorial date July 7, 2026 · Published December 6, 2026

Related articles

Reject fractional cent amounts

A numeric type cannot by itself guarantee whole cents. Validate integrality where money enters the typed part of the application.

Infer route names from a registry

A route registry can drive both lookup and allowed route names. Type the keys from the registry so a removed route cannot survive in a separate union.