Skip to content

chore(deps): migrate to zod 4 - #683

Merged
rubenvdlinde merged 1 commit into
developmentfrom
chore/zod-4-renamed-safeparsereturntype
Sep 8, 2026
Merged

rubenvdlinde merged 1 commit into
developmentfrom
chore/zod-4-renamed-safeparsereturntype

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

Supersedes #613, which fails Frontend Tests (unit) on two zod 4 breaking changes. Both are in our code, not in the bump.

1. SafeParseReturnType is gone

zod 4 exports ZodSafeParseResult<T> — one type parameter where the old one took two. Eleven entity validate() methods declared SafeParseReturnType<TX, unknown>.

The parameter that survives is the second one. zod 3 read SafeParseReturnType<Input, Output> as SafeParseSuccess<Output> | SafeParseError<Input>, so these methods have always returned unknown on success.

Translating them to ZodSafeParseResult<TX> looks like the obvious move and is wrong — it tightens the success type, and tsc rejected it:

Type '{ ...; }' is not assignable to type 'TZaak'.
  Property 'id' is optional in type '{ ... }' but required in type 'TZaak'.

The schemas do not match their entity types. ZodSafeParseResult<unknown> is the faithful translation and leaves every caller reading exactly what it read before. Whether those annotations should be tightened is a real question, but it is a separate one from a dependency bump.

2. z.record() now requires an explicit key type

One site: z.record(z.any()) → z.record(z.string(), z.any()).

How these were found

By the compiler, not by reading release notes. The first attempt took the suite from 18 failing to 12, and the remaining 24 diagnostics were all TS2554 pointing at that single z.record line.

Verification

npm test — the jest runner that was actually failing, not the vitest one — 24 suites, 43 tests, all passing, exit 0.

🤖 Generated with Claude Code

Supersedes #613, which fails Frontend Tests on two zod 4 breaking
changes. Both are in our code, not in the bump.

1. `SafeParseReturnType` is gone. zod 4 exports `ZodSafeParseResult<T>`,
   with ONE type parameter where the old one took two. Eleven entity
   `validate()` methods declared `SafeParseReturnType<TX, unknown>`.

   THE PARAMETER THAT SURVIVES IS THE SECOND ONE. zod 3 read
   `SafeParseReturnType<Input, Output>` as
   `SafeParseSuccess<Output> | SafeParseError<Input>`, so these methods
   have always returned `unknown` on success. Translating them to
   `ZodSafeParseResult<TX>` looks like the obvious move and is wrong: it
   tightens the success type, and tsc rejected it because the schemas do
   not match their entity types — `id` is optional in the schema and
   required in `TZaak`. `ZodSafeParseResult<unknown>` is the faithful
   translation and leaves every caller reading exactly what it read
   before. Whether those annotations SHOULD be tightened is a separate
   question from a dependency bump.

2. `z.record()` now requires an explicit key type. One site,
   `z.record(z.any())` -> `z.record(z.string(), z.any())`.

Found by the compiler, not by reading release notes: the first attempt
went 18 failing suites -> 12, and the remaining 24 diagnostics were all
TS2554 on that one `z.record` line.

Verified locally rather than left to CI: `npm test` (jest, the runner
that was failing) — 24 suites, 43 tests, all passing, exit 0.
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/zaakafhandelapp @ 06ab460

Check PHP Vue Security License Tests
lint ✅
phpcs ✅
phpmd ✅
psalm ✅
phpstan ✅
phpmetrics ✅
eslint ✅
stylelint ✅
build ✅
check-manifest ✅
test-l10n ✅
format ✅
composer ✅ ✅ 100/100
npm ✅ ✅ 546/546
app:check-code ⏭️
info.xml ✅
REUSE ❌
PHPUnit ✅
Newman ✅
Playwright ✅
Hydra gates ✅

Quality workflow — 2026-09-08 16:45 UTC

Download the full PDF report from the workflow artifacts.

@rubenvdlinde
rubenvdlinde merged commit 65c650e into development Sep 8, 2026
48 checks passed
@rubenvdlinde
rubenvdlinde deleted the chore/zod-4-renamed-safeparsereturntype branch September 8, 2026 16:47
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