prefer-zod-parse-output-type
Consider deriving validated return contracts from the Zod schema when the schema owns the contract.
Why
A hand-written contract can drift from the runtime-validated value. Schema ownership determines whether deriving the type preserves the domain architecture.
Fix
When the schema owns the contract, derive it with z.output<typeof Schema>. Preserve independently owned domain and public API contracts, and validate schema compatibility with those contracts.
Examples
export interface ParsedRow { id: string;}import { z } from "zod";import type { ParsedRow } from "./contracts.js";const RowSchema = z.object({ id: z.string() });function load(): ParsedRow { return RowSchema.parse({});}import { z } from "zod";const RowSchema = z.object({ id: z.string() });type Row = z.output<typeof RowSchema>;function load(): Row { return RowSchema.parse({});}