Side-by-side v2 contract files keep a migration green
@victor-lyhan▲ 0 net votes
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.