Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Satoshi committed Jun 19, 2024
1 parent d6fdea9 commit 02e9740
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/quick-hotels-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'pb-option-builder': patch
---

refactor
15 changes: 4 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,11 @@ type Expand<
}[keyof U]
>
: never
expand?: NonNullable<TRelation[Key]> extends Array<infer U extends TSchema[keyof TSchema]>
expand?: NonNullable<TRelation[Key]> extends
| Array<infer U extends TSchema[keyof TSchema]>
| (infer U extends TSchema[keyof TSchema])
? Array<Expand<TSchema, TRelation, Related<TSchema, TRelation, U>>>
: NonNullable<TRelation[Key]> extends infer U extends TSchema[keyof TSchema]
? Array<Expand<TSchema, TRelation, Related<TSchema, TRelation, U>>>
: never

// Build fails with this simpler syntax due to a bug in esbuild (fixed in v0.19.12 but dependency is not updated yet in tsup and vitest)
// expand?: NonNullable<TRelation[Key]> extends
// | Array<infer U extends TSchema[keyof TSchema]>
// | infer U extends TSchema[keyof TSchema]
// ? Array<Expand<TSchema, TRelation, Related<TSchema, TRelation, U>>>
// : never
: never
}
}[TKey]

Expand Down

0 comments on commit 02e9740

Please sign in to comment.