TypeScript Utility Types
Built-in utility types transform an existing contract. Pick, Omit, Partial, Required, Readonly and Record each express a different relationship; none performs a runtime transformation.
How it works
A desk card needs only a code and count, while an editable note patch may omit a note. Pick makes the smaller read model explicit. Partial makes fields optional, which is not the same as allowing an invalid value in a present field. Other utilities help describe function results and unions: ReturnType, Parameters, Awaited, Exclude and Extract are useful when the relationship is real and documented.
Run the code
Try in playground loads this source without running it. Choose Run when ready. The existing TypeScript 5.8.3 worker transpiles and executes one file; it does not perform full semantic type checking, load npm imports or provide DOM/Node APIs. Use the local compiler for the type contract.
For a full check, save the three downloads together in a new folder, run npm install, then npm run check. Use npm run build followed by npm start to execute the checked JavaScript with Node. The supplied project enables strict checking, indexed-access checks and exact optional properties.
Example
type Lot = { code: string; packets: number; note: string };
type DeskCard = Pick<Lot, "code" | "packets">;
type NotePatch = Partial<Pick<Lot, "note">>;
const card: DeskCard = { code: "BE-3", packets: 8 };
const patch: NotePatch = { note: "Keep dry" };
console.log(card.code, card.packets);
console.log(patch.note ?? "No change");
Expected result
BE-3 8 Keep dry
The values are constructed explicitly; Pick did not remove fields from a larger runtime object. Required removes optional markers but does not make a nullable field non-null. Readonly is shallow. Review the resulting type in the editor rather than infer its exact meaning from a utility’s friendly name.