Parent: #548
Problem
After #666–#669, the complete mapped/conditional/Extract/indexed-access handler graph transfers losslessly when its dependencies use named type imports. The equivalent three-module declaration loses contextual callback types when the exporting module spells the same dependencies through a namespace import:
// schemas.ts
export interface A { _zod: { def: { type: "a" } }; a: number }
export interface B { _zod: { def: { type: "b" } }; b: string }
export interface TypeDef { type: "a" | "b" }
export type Types = A | B;
// visit.ts
import * as schemas from "./schemas.js";
type Kind = schemas.TypeDef["type"];
type TypeOfKind<K extends Kind> = Extract<schemas.Types, { _zod: { def: { type: K } } }>;
export type Handlers = { [K in Kind]?: (item: TypeOfKind<K>, rewritten: boolean) => schemas.Types };An imported overloaded call with handler property a is exact under TypeScript 6.0.3 and the native preview: callback item is A, rewritten is boolean, and the only diagnostics are deliberate TS2322/TS2339 controls. ReleaseFast Home emits two false TS7006 diagnostics and misses those controls.
Changing only import * as schemas plus schemas.X references to equivalent named type imports makes Home match. This isolates qualified namespace reference admission in the Program declaration schema, not mapped keys, overload selection, Extract, indexed access, or the consumer call.
Zod 4.5.2 contains the same qualified-reference boundary in core/visit.ts,
but its much larger declaration graph remains an admission audit rather than
proof that this is the last handler edge. A disposable named-import control
must determine whether an additional downstream unsupported edge remains.
Fair strict oracle
- Three real modules with
NodeNext,strict, andnoEmit. - Same files and root order for TypeScript 6.0.3, native TypeScript, and ReleaseFast Home.
- Named-import spelling is a differential control, not the benchmark target.
- Valid
"a"and"b", invalid key, wrong assignment, missing discriminated member, and missing boolean member remain independent controls.
Acceptance
- Preserve a namespace-qualified reference as an ordinary declaration edge when its complete source-owned declaration graph is already losslessly supported.
- Apply the same support proof used for unqualified declaration graphs; do not admit opaque leaves, contextual-only declarations, unsupported utilities, classes/functions with unsafe semantics, or partially transferable graphs as whole types.
- Preserve declaration and type-parameter identity across the transitive
schemas.ts→visit.ts→ consumer boundary. - Keep projection-only behavior for genuinely unsupported qualified graphs and keep existing qualified callable-shell behavior unchanged.
- Add permanent schema and Program regressions for namespace-qualified mapped/conditional/indexed handler graphs plus rejected unsupported controls.
- Match the exact TypeScript 6.0.3/native diagnostic multiset with no TS7006/TS2345.
- Run complete Program/checker suites, ReleaseFast, formatting, whitespace, and required Pickier.
- Run the unchanged pinned Zod 4.5.2 graph twice, require zero additions, and document exact removals or unchanged results.
- Publish the detailed audit and linked README table.
No Zod/package/path/name/property/line special cases, source-text matching, namespace flattening, broad any, fabricated members, or callback-value-driven overload selection.