Skip to content

Commit

Permalink
doc: Document Infer type
Browse files Browse the repository at this point in the history
  • Loading branch information
vbudovski committed Dec 24, 2024
1 parent e5b46ce commit 2eed498
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions paseri-docs/src/content/docs/reference/Schema/common.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,22 @@ if (result.ok) {
// result.value is of type `bigint`.
}
```

## Types

### `Infer`

You can use the `Infer` type to determine the result type of any schema. This is useful, because you don't want to
manually define a type that could easily get out of sync with the schema definition.

```typescript
import * as p from '@vbudovski/paseri';

const schema = p.object({
foo: p.string(),
bar: p.number(),
})

type MySchema = p.Infer<typeof schema>;
// MySchema will be { foo: string, bar: number }.
```

0 comments on commit 2eed498

Please sign in to comment.