Skip to content

Commit

Permalink
fix(JsonSafe): handle nested structures and arrays
Browse files Browse the repository at this point in the history
- Update JsonSafe<T> type to recursively handle nested objects and arrays
  • Loading branch information
0xpatrickdev committed Jul 3, 2024
1 parent 251a735 commit 5812e73
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 5812e73

Please sign in to comment.