Skip to content

Commit

Permalink
fix: improve parse input type
Browse files Browse the repository at this point in the history
  • Loading branch information
ASafaeirad committed Apr 13, 2024
1 parent 7f7e5bd commit ea092fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
InferSchema,
ObjectPath,
Prettify,
RecursivePartial,
RequiredSchema,
} from './types';

Expand All @@ -19,7 +20,7 @@ export class Config<TSchema extends Record<string, Schema<any, any, boolean>>> {

constructor(private schema: TSchema) {}

public parse(value: Partial<Record<keyof TSchema, any>>) {
public parse(value: RecursivePartial<InferSchema<TSchema>>) {
this.value = value as Record<keyof TSchema, any>;

Object.entries(this.schema).forEach(([key, s]) => {
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@ export type GetPath<T, P extends string> = P extends keyof T
? GetPath<T[K], Rest>
: never
: T;

export type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;
};

0 comments on commit ea092fc

Please sign in to comment.