Open this example in the interactive library
Source code
type Events = {
start: { id: number };
finish: { ms: number };
failure: { reason: string };
};
console.log(
((payload: Pick<Events, "start" | "finish">) => payload.finish.ms)({
start: { id: 1 },
finish: { ms: 20 },
}),
);
Sample output
20
