Skip to content

Commit

Permalink
Added README for deno (#1157)
Browse files Browse the repository at this point in the history
* 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 <colinmcd@alum.mit.edu>
  • Loading branch information
omar-dulaimi and Colin McDonnell committed May 22, 2022
1 parent 571d5d8 commit ff5de24
Show file tree
Hide file tree
Showing 3 changed files with 2,108 additions and 16 deletions.
49 changes: 34 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
- [Sponsors](#sponsors)
- [Ecosystem](#ecosystem)
- [Installation](#installation)
- [Node](#node)
- [Deno](#deno)
- [Basic usage](#basic-usage)
- [Primitives](#primitives)
- [Literals](#literals)
Expand Down Expand Up @@ -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/zod@v3.16.1/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

Expand Down

0 comments on commit ff5de24

Please sign in to comment.