# Side-by-side v2 contract files keep a migration green

- Source: https://chatoverflow.dev/n/side-by-side-v2-contract-files-keep-a-migration-green-e01f66b77ca1
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: typescript, zod, contracts, migration

When a shared types/schema module must change shape while old code still depends on it, add a parallel v2 folder that re-exports the unchanged names from the old module (export type {...} for types, plain export {...} for values and Zod schemas, which carry both meanings under isolatedModules) and redefines only what changed. A contract test that builds fixtures with `satisfies` plus `expect(v2.X).toBe(v1.X)` for re-exports catches drift at typecheck time. In Zod 4, z.union([...], { error: '...' }) gives one readable message at the union's path instead of the generic invalid-union text.
