Skip to content

Commit

Permalink
Add tsc compilation test
Browse files Browse the repository at this point in the history
  • Loading branch information
colinhacks committed Mar 5, 2023
1 parent 5b304ae commit 20df80e
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 62 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,6 +1,7 @@
**/.DS_Store
node_modules
/lib
/__buildtest__
coverage
.vscode
.idea
Expand Down
107 changes: 55 additions & 52 deletions package.json
@@ -1,10 +1,42 @@
{
"name": "zod",
"version": "3.21.0",
"description": "TypeScript-first schema declaration and validation library with static type inference",
"author": "Colin McDonnell <colin@colinhacks.com>",
"repository": {
"type": "git",
"url": "https://github.com/colinhacks/zod"
},
"main": "./lib/index.js",
"types": "./index.d.ts",
"module": "./lib/index.mjs",
"devDependencies": {
"@rollup/plugin-typescript": "^8.2.0",
"@types/benchmark": "^2.1.0",
"@types/jest": "^29.2.2",
"@types/node": "14",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"benchmark": "^2.1.4",
"dependency-cruiser": "^9.19.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-ban": "^1.6.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"husky": "^7.0.4",
"jest": "^29.3.1",
"lint-staged": "^12.3.7",
"nodemon": "^2.0.15",
"prettier": "^2.6.0",
"pretty-quick": "^3.1.3",
"rollup": "^2.70.1",
"ts-jest": "^29.0.3",
"ts-morph": "^14.0.0",
"ts-node": "^10.9.1",
"tslib": "^2.3.1",
"tsx": "^3.8.0",
"typescript": "~4.5.0"
},
"exports": {
".": {
"require": "./lib/index.js",
Expand All @@ -14,35 +46,30 @@
"./package.json": "./package.json",
"./locales/*": "./lib/locales/*"
},
"bugs": {
"url": "https://github.com/colinhacks/zod/issues"
},
"description": "TypeScript-first schema declaration and validation library with static type inference",
"files": [
"/lib",
"/index.d.ts"
],
"repository": {
"type": "git",
"url": "https://github.com/colinhacks/zod"
},
"author": "Colin McDonnell <colin@colinhacks.com>",
"license": "MIT",
"sideEffects": false,
"bugs": {
"url": "https://github.com/colinhacks/zod/issues"
},
"homepage": "https://zod.dev",
"funding": "https://github.com/sponsors/colinhacks",
"support": {
"backing": {
"npm-funding": true
}
},
"homepage": "https://zod.dev",
"keywords": [
"typescript",
"schema",
"validation",
"type",
"inference"
],
"dependencies": {},
"license": "MIT",
"lint-staged": {
"src/*.ts": [
"eslint --cache --fix",
"prettier --ignore-unknown --write"
]
},
"scripts": {
"prettier:check": "prettier --check src/**/*.ts deno/lib/**/*.ts --no-error-on-unmatched-pattern",
"prettier:fix": "prettier --write src/**/*.ts deno/lib/**/*.ts --ignore-unknown --no-error-on-unmatched-pattern",
Expand All @@ -56,6 +83,7 @@
"build:esm": "rollup --config rollup.config.js",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:types": "tsc -p tsconfig.types.json",
"build:test": "tsc -p tsconfig.test.json",
"rollup": "rollup --config rollup.config.js",
"test:watch": "jest --watch",
"test": "jest --coverage",
Expand All @@ -66,39 +94,14 @@
"benchmark": "tsx src/benchmarks/index.ts",
"prepare": "husky install"
},
"devDependencies": {
"@rollup/plugin-typescript": "^8.2.0",
"@types/benchmark": "^2.1.0",
"@types/jest": "^29.2.2",
"@types/node": "14",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"benchmark": "^2.1.4",
"dependency-cruiser": "^9.19.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-ban": "^1.6.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"husky": "^7.0.4",
"jest": "^29.3.1",
"lint-staged": "^12.3.7",
"nodemon": "^2.0.15",
"prettier": "^2.6.0",
"pretty-quick": "^3.1.3",
"rollup": "^2.70.1",
"ts-jest": "^29.0.3",
"ts-morph": "^14.0.0",
"ts-node": "^10.9.1",
"tslib": "^2.3.1",
"tsx": "^3.8.0",
"typescript": "~4.5.0"
"sideEffects": false,
"support": {
"backing": {
"npm-funding": true
}
},
"lint-staged": {
"src/*.ts": [
"eslint --cache --fix",
"prettier --ignore-unknown --write"
]
"types": "./index.d.ts",
"dependencies": {
"zod": "canary"
}
}
22 changes: 12 additions & 10 deletions playground.ts
@@ -1,12 +1,14 @@
import { z } from "./src";

console.time("parse");
// for (let i = 0; i < 1000000; i++) {
// z.string().safeParse(123);
// }
const result = z.string().safeParse(123);
if (result.success === false) {
console.log(result.error);
console.log(result.error === result.error);
}
console.timeEnd("parse");
const a = z.object({ a: z.string() });
const b = z.object({ a, b: z.string() });
const c = z.object({ a, b, c: z.string() });
const d = z.object({ a, b, c, d: z.string() });
const e = z.object({ a, b, c, d, e: z.string() });
const f = z.object({ a, b, c, d, e, f: z.string() });
const g = z.object({ a, b, c, d, e, f, g: z.string() });
const h = z.object({ a, b, c, d, e, f, g, h: z.string() });
const i = z.object({ a, b, c, d, e, f, g, h, i: z.string() });
const j = z.object({ a, b, c, d, e, f, g, h, i, j: z.string() });

export const arg = j.parse({});
12 changes: 12 additions & 0 deletions tsconfig.test.json
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "__buildtest__",
"target": "es5",
"declaration": true,
"declarationMap": false,
"sourceMap": false
},
"exclude": []
}

0 comments on commit 20df80e

Please sign in to comment.