Skip to content

Instantly share code, notes, and snippets.

View jeremyhewett's full-sized avatar

Jeremy Hewett jeremyhewett

  • Diligent
  • Vancouver, BC
View GitHub Profile
@jeremyhewett
jeremyhewett / example.ts
Last active October 30, 2024 10:03
A Typescript generic to describe any object (or primitive) that has gone through JSON serialization and deserialization. Using JSON.stringify to serialize an object and then using JSON.parse to deserialize it will produce a result that can differ from the original in many ways. For instance, any function properties will be removed, any Date prop…
interface Entity {
id: string;
name?: string;
createdAt: Date;
updatedAt: Date | null;
props: { [key: string]: unknown };
related?: Entity[];
size: bigint;
}