A narrow payload type describes the exact field a function needs. Keep that contract separate from the larger database record.
Worked example
type Events = {
start: { id: number };
finish: { ms: number };
failure: { reason: string };
};
console.log(((ms: Events["finish"]["ms"]) => ms / 1000)(250));Result
0.25Implementation notes
A narrow interface can improve reuse by avoiding dependencies on unrelated fields. Validate external payloads before passing them into the function.
Try it yourself
Pass an object literal with a misspelled key and inspect the compiler diagnostic.
Open the TypeScript example →Editorial date November 18, 2025 · Published December 6, 2026