commit 59cc377899246081e50f076d9396a184aba45f61 Author: abearxiong Date: Fri Jan 16 22:34:12 2026 +0800 初始化项目结构,添加 .gitignore、package.json、pnpm-lock.yaml 和 src/index.ts 文件 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66cf2c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# Dependencies +node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +# Testing +coverage/ +*.lcov + +# Production +dist/ +build/ +out/ + +# Misc +.DS_Store +*.pem + +# Debug +*.log +logs/ + +# Editor +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# TypeScript +*.tsbuildinfo + +# Environment variables +.env +.env.local +.env.*.local + +# Temporary files +*.tmp +.cache/ diff --git a/package.json b/package.json new file mode 100644 index 0000000..393bd40 --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "test-zod", + "version": "0.0.1", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "abearxiong (https://www.xiongxiao.me)", + "license": "MIT", + "packageManager": "pnpm@10.14.0", + "type": "module", + "dependencies": { + "zod": "^4.3.5" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..007e842 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,22 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + zod: + specifier: ^4.3.5 + version: 4.3.5 + +packages: + + zod@4.3.5: + resolution: {integrity: sha512-k7Nwx6vuWx1IJ9Bjuf4Zt1PEllcwe7cls3VNzm4CQ1/hgtFUK2bRNG3rvnpPUhFjmqJKAKtjV576KnUkHocg/g==} + +snapshots: + + zod@4.3.5: {} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..d3f615c --- /dev/null +++ b/src/index.ts @@ -0,0 +1,7 @@ +import { z } from 'zod' + +const name = z.string().optional().describe('The name of the user') +// name.optional() +// console.log(name.description) // Output: The name of the user + +console.log(JSON.stringify(name), name.description) // Output: The name of the user \ No newline at end of file