Skip to content

Commit

Permalink
added useTypeAssertions to support zod > 3.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishoermann committed Nov 8, 2023
1 parent 0a9cd70 commit b818c0b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions packages/generator/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Be aware that some generator options have been removed, a few new ones have been
- [`useDefaultValidators`](#usedefaultvalidators)
- [`coerceDate`](#coercedate)
- [`writeNullishInModelTypes`](#writenullishinmodeltypes)
- [`useTypeAssertions`](#usetypeassertions)
- [`prismaClientPath`](#prismaclientpath)
- [Skip schema generation](#skip-schema-generation)
- [Custom Enums](#custom-enums)
Expand Down Expand Up @@ -556,6 +557,22 @@ generator zod {
}
```

### `useTypeAssertions`

> default: false
Since there is a known typscript error when using `zod` greater than `3.21.1` you can now use type assertions to circumvent the error and use the latest version of `zod`.

> A WORD OF WARNING: Use this solution at your own risk! Because type assertions are circumventing the type system this can lead to unexpected behavior and runtime errors.
> But since the types worked in `zod` version `3.21.1` and the error is a known issue in `zod` version `3.21.2` I think it might be a valid solution until the issue is resolved.
```prisma
generator zod {
// ...rest of config
useTypeAssertions = true
}
```

### `prismaClientPath`

> default: `inferred from prisma schema path`
Expand Down
2 changes: 1 addition & 1 deletion packages/generator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zod-prisma-types",
"version": "3.0.0",
"version": "3.1.0",
"description": "Generates zod schemas from Prisma models with advanced validation",
"author": "Chris Hörmann",
"license": "MIT",
Expand Down

0 comments on commit b818c0b

Please sign in to comment.