-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add deno README * Copy README to deno lib * Refactor build deno script * Update installation notes * fix typo * Clean up deno instructions Co-authored-by: Colin McDonnell <[email protected]>
- Loading branch information
1 parent
571d5d8
commit ff5de24
Showing
3 changed files
with
2,108 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,8 @@ | |
- [Sponsors](#sponsors) | ||
- [Ecosystem](#ecosystem) | ||
- [Installation](#installation) | ||
- [Node](#node) | ||
- [Deno](#deno) | ||
- [Basic usage](#basic-usage) | ||
- [Primitives](#primitives) | ||
- [Literals](#literals) | ||
|
@@ -288,30 +290,47 @@ There are a growing number of tools that are built atop or support Zod natively! | |
|
||
## Installation | ||
|
||
### Requirements | ||
|
||
- TypeScript 4.1+! | ||
- You must enable `strict` mode in your `tsconfig.json`. This is a best practice for all TypeScript projects. | ||
|
||
```ts | ||
// tsconfig.json | ||
{ | ||
// ... | ||
"compilerOptions": { | ||
// ... | ||
"strict": true | ||
} | ||
} | ||
``` | ||
|
||
### Node/NPM | ||
|
||
To install Zod v3: | ||
|
||
```sh | ||
npm install zod | ||
npm install zod # npm | ||
yarn add zod # yarn | ||
pnpm add zod # pnpm | ||
``` | ||
|
||
### Deno | ||
|
||
Unlike Node, Deno relies on direct URL imports instead of a package manager like NPM. Zod is available on [deno.land/x](deno.land/x). The latest version can be imported like so: | ||
|
||
```ts | ||
import { z } from "https://deno.land/x/zod/mod.ts"; | ||
``` | ||
|
||
⚠️ IMPORTANT: You must enable `strict` mode in your `tsconfig.json`. This is a best practice for all TypeScript projects. | ||
You can also specify a particular version: | ||
|
||
```ts | ||
// tsconfig.json | ||
{ | ||
// ... | ||
"compilerOptions": { | ||
// ... | ||
"strict": true | ||
} | ||
} | ||
import { z } from from "https://deno.land/x/[email protected]/mod.ts" | ||
``` | ||
|
||
> **TypeScript requirements** | ||
> | ||
> - Zod 3.x requires TypeScript 4.1+ | ||
> - Zod 2.x requires TypeScript 3.7+ | ||
> - Zod 1.x requires TypeScript 3.3+ | ||
> The rest of this README assumes you are using NPM and importing directly from the `"zod"` package. | ||
|
||
## Basic usage | ||
|
||
|
Oops, something went wrong.