Skip to content

Commit

Permalink
improve(types): use simplify for more readable result types
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Oct 3, 2024
1 parent bfd427a commit 77ac82b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/layers/3_ResultSet/infer/root.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Simplify } from 'type-fest'
import { AssertIsEqual, type ExcludeNull, type GetKeyOr, type StringKeyof } from '../../../lib/prelude.js'
import type { TSError } from '../../../lib/TSError.js'
import type { Schema } from '../../1_Schema/__.js'
Expand Down Expand Up @@ -40,10 +41,10 @@ export type InferObject<$SelectionSet, $Schema extends SchemaIndex, $Node extend
// todo what about when scalars wildcard is combined with other fields like relations?
? InferSelectScalarsWildcard<$SelectionSet, $Schema,$Node>
:
(
Simplify<(
& InferSelectionNonSelectAlias<$SelectionSet, $Schema, $Node>
& InferSelectionSelectAlias<$SelectionSet, $Schema, $Node>
)
)>

// dprint-ignore
type InferSelectionNonSelectAlias<$SelectionSet , $Schema extends SchemaIndex, $Node extends Schema.Output.Object$2> =
Expand Down
4 changes: 3 additions & 1 deletion src/layers/6_client/handleOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ type IfConfiguredGetOutputErrorReturns<$Config extends Config> =

// dprint-ignore
type IfConfiguredStripSchemaErrorsFromDataRootType<$Config extends Config, $Index extends SchemaIndex, $Data> =
{ [$RootFieldName in keyof $Data]: IfConfiguredStripSchemaErrorsFromDataRootField<$Config, $Index, $Data[$RootFieldName]> }
Simplify<{
[$RootFieldName in keyof $Data]: IfConfiguredStripSchemaErrorsFromDataRootField<$Config, $Index, $Data[$RootFieldName]>
}>

// dprint-ignore
type IfConfiguredStripSchemaErrorsFromDataRootField<$Config extends Config, $Index extends SchemaIndex, $Data> =
Expand Down

0 comments on commit 77ac82b

Please sign in to comment.