Skip to content

Commit

Permalink
fix(lib): add recursion to unwrapping of typescript model types
Browse files Browse the repository at this point in the history
#Patch release
  • Loading branch information
Harjot1Singh committed Oct 15, 2022
1 parent f26fe0a commit 309b339
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ declare module '@shabados/database' {

export type { Model, ModelObject, QueryBuilder }

type RecursiveHelper<T> = { [P in keyof T]: UnwrapRecursive<T[P]> }

export type UnwrapRecursive<M> = M extends Model
? RecursiveHelper<ModelObject<M>>
: RecursiveHelper<M>

export type UnwrapModel<M extends Model> = UnwrapRecursive<M>

export const knex: ReturnType<Model['$knex']>

export type CommonBuilder<M extends Model> = QueryBuilder<M> & {
Expand Down

0 comments on commit 309b339

Please sign in to comment.