Dev Helpers
← Back

Record event-specific histories

Record event-specific histories using TypeScript.

Open this example in the interactive library

Source code

type Events = {
  start: { id: number };
  finish: { ms: number };
  failure: { reason: string };
};
console.log(
  (
    { start: [{ id: 1 }], finish: [], failure: [] } satisfies {
      [K in keyof Events]: Events[K][];
    }
  ).start,
);

Sample output

[ { id: 1 } ]