Skip to content

Commit

Permalink
types: export SerializeTuple and SerializeObject (#1907)
Browse files Browse the repository at this point in the history
  • Loading branch information
noook authored Nov 17, 2023
1 parent a3120b6 commit 811d693
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/types/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ export type Serialize<T> =
never;

/** JSON serialize [tuples](https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types) */
type SerializeTuple<T extends [unknown, ...unknown[]]> = {
export type SerializeTuple<T extends [unknown, ...unknown[]]> = {
[k in keyof T]: T[k] extends NonJsonPrimitive ? null : Serialize<T[k]>;
};

/** JSON serialize objects (not including arrays) and classes */
type SerializeObject<T extends object> = {
export type SerializeObject<T extends object> = {
[k in keyof Omit<T, FilterKeys<T, NonJsonPrimitive>>]: Serialize<T[k]>;
};

Expand Down

0 comments on commit 811d693

Please sign in to comment.