Skip to content

Make z.properties() a check again - #6594

Merged
colinhacks merged 1 commit into
mainfrom
properties-check-only
Sep 12, 2026
Merged

colinhacks merged 1 commit into
mainfrom
properties-check-only

Conversation

@colinhacks

Copy link
Copy Markdown
Owner

Reverts the schema role that #6536 gave z.properties(). It is a check again, as in 4.5: it spreads into .check(), and z.instanceof().properties() stays as sugar over it. The standalone form is gone — z.properties(shape).parse(), z.infer of it, z.toJSONSchema() and z.compile() of it, and the cycle tracking only the schema role had.

The schema form was a trap with transforms. A transform inside the shape ran and was discarded, so the parsed value and the inferred type were both the input side, and writing the result back is not an option for the objects the feature exists for: assigning to a getter-only property such as Response.status throws. As a check, "the value is never changed" is what a check already means.

What stays: every failing key reports, symbol keys, the params argument, and compile support. The check now lives next to $ZodCheckProperty as $ZodCheckProperties and installs its Symbol.iterator as an own property, so the symbol-key loop in util.members and the memoizer's callable arm go with the schema role. The API reference drops the standalone paragraph; the 4.6 post already led with the method.

Bundle, gzipped from the built package: mini −17 / −16 / −16 on boolean / string / object, classic −35 / −38 / −44, the named import −447. Runtime and memory: the check body is the same code moved, construction pays one Object.defineProperty per z.properties() call, and each check instance carries one extra own property.

This removes an API that shipped in 4.6.0.

Copilot AI lite review requested due to automatic review settings September 12, 2026 17:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes across the check implementation, Classic/Mini exports, compiler, JSON Schema conversion, traversal, memoization, tests, and documentation.

  • Check-only API: Moves z.properties() into $ZodCheckProperties, preserving direct and spread .check() usage, async validation, symbol keys, and input-side narrowing through .properties().
  • Schema removal: Removes standalone parsing, inference, JSON Schema conversion, and cycle support. This intentionally removes an API shipped in 4.6.0, as acknowledged in the PR description.
  • Shared cleanup: Retains check compilation while removing schema-only dispatch and support code; no live internal consumers of the removed schema types were found.

Local validation passed: 415 test files, 6,632 tests, and no type errors, covering v4, compile-mode, documentation examples, and Mini exports. Performance and bundle deltas were not independently remeasured.

Pullfrog  | View workflow run | Using GPT Astra | 𝕏

@colinhacks
colinhacks merged commit 413cce9 into main Sep 12, 2026
9 checks passed
@colinhacks
colinhacks deleted the properties-check-only branch September 12, 2026 17:59
@colinhacks

Copy link
Copy Markdown
Owner Author

Landed in v4.6.3.

colinhacks added a commit that referenced this pull request Sep 13, 2026
…ab (#6598)

z.properties() is a check again since #6594, so the section now opens with
the spread form both Zod and Zod Mini have, in a tab pair. The z.instanceof()
method follows as the Zod-only sugar that narrows the inferred type.

Also states that z.instanceof() returns the exact object passed in. The
no-clone fact moves up to the Instanceof intro, where it covers every
instance schema rather than just the properties check.

This branch was successfully deployed

1 active deployment
Preview – zod-v4 — 65be4a17 Deployed Sep 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants