Skip to content

Commit

Permalink
fix(parser-schemas): assert return types for document schema creators
Browse files Browse the repository at this point in the history
  • Loading branch information
DASPRiD committed Apr 28, 2024
1 parent 6c8793b commit deca970
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/parser-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ export const createResourceDocumentSchema = <TDeserializer extends AnyResourceDe
links: rootLinksSchema.optional(),
meta: deserializer.documentMetaSchema ?? defaultMetaSchema.optional(),
included: includedSchema.optional(),
});
}) as DocumentSchema<
ResourceSchema<TDeserializer>,
FallbackMetaSchema<InferDocumentMetaSchema<TDeserializer>>
>;

export const createNullableResourceDocumentSchema = <TDeserializer extends AnyResourceDeserializer>(
deserializer: TDeserializer,
Expand All @@ -190,7 +193,10 @@ export const createNullableResourceDocumentSchema = <TDeserializer extends AnyRe
links: rootLinksSchema.optional(),
meta: deserializer.documentMetaSchema ?? defaultMetaSchema.optional(),
included: includedSchema.optional(),
});
}) as DocumentSchema<
z.ZodNullable<ResourceSchema<TDeserializer>>,
FallbackMetaSchema<InferDocumentMetaSchema<TDeserializer>>
>;

export const createResourceCollectionDocumentSchema = <
TDeserializer extends AnyResourceDeserializer,
Expand All @@ -205,4 +211,7 @@ export const createResourceCollectionDocumentSchema = <
links: rootLinksSchema.optional(),
meta: deserializer.documentMetaSchema ?? defaultMetaSchema.optional(),
included: includedSchema.optional(),
});
}) as DocumentSchema<
z.ZodArray<ResourceSchema<TDeserializer>>,
FallbackMetaSchema<InferDocumentMetaSchema<TDeserializer>>
>;

0 comments on commit deca970

Please sign in to comment.