schema-fixer icon indicating copy to clipboard operation
schema-fixer copied to clipboard

Update type definitions for the `parse` function

Open gchumillas opened this issue 11 months ago • 0 comments

Context:

The parse function is returning the errors as any[] type:

// src/index.d.ts
export function parse<T extends Schema>(value: any, schema: T): [Value<T>, errors: any[]]

which provides little information about the errors structure.

Possible Fix:

Update src/index.d.ts and replace any[] with something more descriptive. For example:

// src/index.d.ts
export type Errors = string | { path: string; errors: Errors }[]
// ...
export function parse<T extends Schema>(value: any, schema: T): [Value<T>, errors: Errors]

gchumillas avatar Mar 09 '24 10:03 gchumillas