Skip to content

feat: zod v4 uses spread / extend#468

Merged
mnahkies merged 5 commits into
mainfrom
mn/feat/spread-extend
May 25, 2026
Merged

feat: zod v4 uses spread / extend#468
mnahkies merged 5 commits into
mainfrom
mn/feat/spread-extend

Conversation

@mnahkies
Copy link
Copy Markdown
Owner

previously we were using a combination of the deprecated merge and intersection for creating intersected types.

now we'll

  • Continue to use z.intersection if any of the candidates isn't an object
  • Use s_Thing.extend({ /* properties*/ }) if combining a named schema with anonymous additions
  • Use z.object({ ...s_Thing.shape, ...s_OtherThing.shape }) otherwise

this removes the use of the deprecated merge, and should be more efficient according to the zod documentation, and generally more idiomatic usage of zod.

also takes some steps to "squash" unnecessary intersection types - eg: {a: string} & {b: string} should squash to simply {a: string, b: string}

@mnahkies mnahkies force-pushed the mn/feat/spread-extend branch from 75210ee to cd31380 Compare May 24, 2026 12:27
@mnahkies mnahkies force-pushed the mn/feat/spread-extend branch from cd31380 to aa8c84f Compare May 25, 2026 12:28
@mnahkies mnahkies marked this pull request as ready for review May 25, 2026 12:31
@mnahkies mnahkies enabled auto-merge (squash) May 25, 2026 12:31
@mnahkies mnahkies merged commit 1b551f5 into main May 25, 2026
16 checks passed
@mnahkies mnahkies deleted the mn/feat/spread-extend branch May 25, 2026 12:34
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.

1 participant