Skip to content

Commit

Permalink
Merge pull request #632 from 0xpatrickdev/fix-json-safe
Browse files Browse the repository at this point in the history
fix(JsonSafe): handle nested structures and arrays
  • Loading branch information
Zetazzz authored Jul 11, 2024
2 parents a9b1016 + 5812e73 commit 326289e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/telescope/src/helpers/json-safe.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
export const jsonSafe = `
export type JsonSafe<T> = {
[Prop in keyof T]: T[Prop] extends Uint8Array | bigint | Date ? string : T[Prop];
}
export type JsonSafe<T> = T extends Uint8Array | bigint | Date
? string
: T extends Array<infer U>
? Array<JsonSafe<U>>
: T extends object
? { [K in keyof T]: JsonSafe<T[K]> }
: T;
`;


0 comments on commit 326289e

Please sign in to comment.