ReviewOS

home-lang/home

fix(ts): contextually type Zod core callbacks reported as implicit any

#758
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Parent: #548

On the pinned Zod 4.5.2 core proxy (21 files, strict NodeNext, no emit), where TypeScript 6.0.3 and native TypeScript 7.0.2 report only the one expected TS2307, Home still reports 12 TS7006 and 4 TS7031 implicit-any diagnostics (baseline 832f68544: 59 diagnostics / 59 identities).

Clusters:

SitesCause
util.ts:365, schemas.ts:2425/2507/3725/4841 (TS7006); schemas.ts:2721/3359 (4× TS7031)Promise.resolve/all/race/any on Home's built-in Promise global return any, so the .then callback has no contextual parameter type
compile.ts:1802 (TS7006 + a false TS2554)built-in Array.from accepts one argument, so Array.from(set, (value) => ...) loses mapfn
util.ts:325 (false TS2554)built-in Object.create lacks the properties parameter
api.ts:1696callback passed to a call with explicit type arguments (_check<T>((payload) => ...))
api.ts:1732, 1745array literal of callbacks assigned to a property (ch._zod.onattach = [(inst) => ...])
api.ts:1784, 1785.map callback on a let initialized with params.truthy ?? [...]
util.ts:313set(v) in the descriptor passed to Object.defineProperty

Fairness: fixes mirror lib.d.ts / checker semantics (Awaited, tuple inference from the | [] constraint, literal widening) — no corpus edits, no diagnostic suppression. Each fix is gated on the unchanged corpus against the main baseline (0 added identities) plus both unit suites, and checked against pinned tsgo on minimal repros.

9 days ago

Three of the six clusters are fixed on origin/main:

  • 3f4bea896 — built-in Array.from keeps its optional mapfn, Object.create its property map, and the Object.defineProperty descriptor is PropertyDescriptor & ThisType<any>
  • fb70525ad — Promise.resolve/all/race/any return the structural Promise<T> their lib signatures describe instead of any
  • 0e597ef47 — evidence

On the unchanged 21-file Zod 4.5.2 core shard, against the 832f68544 baseline:

832f68544nowchange
Diagnostics / identities594613 removed; 0 added
TS703140—
TS7006125#765, #763, #764
TS255442—

Checker suite 4,376/4,376 and Program suite 215/215 pass, ReleaseSafe build clean. A 23-case Promise oracle checked one file at a time against pinned tsgo shows no new diagnostics; the three TS7006 it still reports (a type-parameter argument, a union argument, allSettled) are conservative bail-outs that are equally present on main.

Two Home-specific traps are worth recording for future built-in work: internObjectType does not deduplicate, so an identity check against a freshly built type silently never matches (the Promise hook did nothing until the global was cached); and tsc's interface ThisType<T> {} is empty, so the marker must be skipped wherever structure is demanded — the relation engine required every intersection member and produced false TS2345 on every descriptor value until it learned to skip markers.

Known gap kept visible rather than asserted away: Home reports nothing for a descriptor member of the wrong type ({ enumerable: 1 } is TS2322 in tsgo).

The remaining three causes are each a value Home types any for reasons outside this cluster, split out with their diagnoses and the measurements that rejected the obvious fixes: #765 (generic function referenced before its declaration), #763 (imported value whose declared type cannot be transferred), #764 (Record/Pick transfer and mapped types over any).

9 days ago

Progress in 3b3dae8ed5: the forward-generic contextual callback case is fixed without publishing speculative function types.

On the exact Zod v4.5.2 core shard, diagnostics move from 46 to 45 with exactly one removal and no additions: api.ts:1696:25 TS7006. The remaining callback diagnostics are 4 TS7006, with the imported unsupported value projection tracked in #763 and the Record/mapped-type transfer gap tracked in #764. Full checker (4,379/4,379), Program (216/216), ReleaseSafe home-tsc, and the independent TypeScript oracle all pass.

#765 remains open for the broader forward value/overload semantics; this parent remains open until the remaining Zod callback causes are resolved.

9 days ago

Progress in cdad20fe5d: #763 is complete. Projection-only metadata now contextually types callbacks reached through an unsupported imported constructor without publishing an approximate value type.

On the unchanged Zod v4.5.2 core shard, diagnostics move from 45 to 43 with exactly two removals and zero additions: api.ts:1732:6 TS7006 and api.ts:1745:6 TS7006. The shard now has 2 TS7006, both at api.ts:1784–1785 under #764. Checker 4,379/4,379, Program 217/217, ReleaseSafe home-tsc, the TypeScript 6.0.2 oracle, formatting, and focused lint all pass.

This parent remains open for #764.

9 days ago

Closing as completed. Its three remaining child causes are now resolved: #765's contextual callback slice landed in 3b3dae8, #763 is closed via cdad20f, and #764 is closed via 6f26046 with the final two Zod TS7006 identities removed and zero additions. All four commits are ancestors of current origin/main. The broader forward-value semantics intentionally left in #765 remain separately tracked and do not block this callback-diagnostic parent.

Sign in to comment on this issue.