Parent
Problem
After #672, the pinned Zod 4.5.2 graph remains at 374 diagnostics / 369 unique identities. Ten locale TS7006 reports occur because contextual callback typing transported through imported distributive homomorphic utilities does not retain the readable union surface.
The faithful reduction has three modules, matching Zod's imported utility graph. Its MultipleMatch arm omits options; the final Record<string, unknown> intersection makes that property readable as unknown. After the Array.isArray(issue.options) guard, TypeScript deliberately treats the mapped callback value as any.
// utilities.ts
export type Primitive = string | number | symbol | bigint | boolean | null | undefined;
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export type InexactPartial<T> = { [P in keyof T]?: T[P] | undefined };
export type MakePartial<T, K extends keyof T> = Omit<T, K> & InexactPartial<Pick<T, K>>;
export type Identity<T> = T;
export type Flatten<T> = Identity<{ [K in keyof T]: T[K] }>;
// owner.ts
import type * as util from "./utilities.js";
interface IssueBase { readonly code?: string; readonly path: PropertyKey[]; readonly message: string; }
interface NoMatch extends IssueBase { readonly code: "invalid_union"; readonly options?: util.Primitive[]; readonly inclusive?: true; }
interface MultipleMatch extends IssueBase { readonly code: "invalid_union"; readonly inclusive: false; readonly matches: number[]; }
interface Custom extends IssueBase { readonly code: "custom"; }
type Issue = NoMatch | MultipleMatch | Custom;
type RawIssue<T extends IssueBase> = T extends any
? util.Flatten<util.MakePartial<T, "message" | "path"> & { readonly input: unknown } & Record<string, unknown>>
: never;
export type ErrorMap<T extends IssueBase = Issue> = (issue: RawIssue<T>) => string | undefined;
// consumer.ts
import type { ErrorMap } from "./owner.js";
import type { Primitive } from "./utilities.js";
export const error: () => ErrorMap = () => (issue) => {
if (issue.code === "invalid_union" && issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
return issue.options.map((value) => {
const exact: Primitive = value;
const wrong: never = value;
void exact; void wrong;
return `${value}`;
}).join(" | ");
}
return undefined;
};TypeScript 6.0.3 and the native preview each report exactly the intentional TS2322 (any to never), with no TS7006, TS2339, or TS2344.
Requirements
- Preserve exact readable, optional, and open-index structure across imported distributive homomorphic mapped aliases and contextual callback transport.
- Keep normal discriminant, truthiness, and
Array.isArrayflow semantics. - No source/library/member-name special cases, source-text inference, blanket diagnostic suppression, depth caps, or broad
anyexports. - Add focused Program/schema/checker coverage and the exact three-module invalid-control oracle.
- Require exact TS6/native/Home diagnostic parity, full checker and Program suites, ReleaseFast, format/diff checks, and the repository Pickier baseline.
- Run pinned Zod 4.5.2 twice against the exact #672 parent; reject any added diagnostic identity or unstable run.
- Publish detailed evidence and a linked README table, including negative results if the corpus does not improve.