gchumillas/schema-fixer

Update type definitions for the `parse` function

Opened this issue · 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]