Dev Helpers
← Back

Extend a record with metadata

Extend a record with metadata using TypeScript.

Open this example in the interactive library

Source code

interface Job {
  id: number;
  name: string;
  done: boolean;
}
const job: Job = { id: 1, name: "Build", done: false };
console.log({ ...job, attempts: 2 } satisfies Job & { attempts: number });

Sample output

{ id: 1, name: 'Build', done: false, attempts: 2 }