Commit bf72c41
committed
fix(docs): teach composition, not .extend — and stop depending on which FieldSchema declaration you get
CI rejected the first fix: `FieldSchema.in.extend(…)` passed locally and failed
with "Property 'in' does not exist on type 'ZodObject<…>'" on the runner. The two
builds emit DIFFERENT declarations for the same source — locally
z.ZodPipe<z.ZodObject<…>>, in CI a plain z.ZodObject.
The runtime is unambiguous: after `rm -rf dist && pnpm build`, FieldSchema is a
`bound ZodPipe` with `.extend === undefined` and `.in` a ZodObject. So CI's
declaration contradicts the value it describes — `.extend()` type-checks there and
throws at runtime. That is a real spec-side divergence (likely inference
instability in the DTS bundling of these very large zod types) and deserves its
own investigation; it is not something this docs fix should paper over.
So the checked example now uses only `.parse()`: parse with FieldSchema, validate
the additions alongside it. Correct under either declaration, verified to run, and
better advice anyway — composition keeps the transform, which `.extend()` discards.
`.in.extend()` stays in prose as the merged-schema route with that caveat.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ajwvrmd1hDC9RBofYBhGuR1 parent 2325706 commit bf72c41
2 files changed
Lines changed: 34 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
27 | 38 | | |
28 | 39 | | |
29 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
367 | 370 | | |
368 | 371 | | |
369 | 372 | | |
370 | 373 | | |
371 | 374 | | |
372 | 375 | | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
378 | 381 | | |
379 | | - | |
| 382 | + | |
380 | 383 | | |
381 | 384 | | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
386 | 390 | | |
387 | 391 | | |
388 | 392 | | |
| |||
0 commit comments