fix(resolve): type TypeScript getters and stop plain constructor parameters standing in for fields
c.req.header() produced no call edge in hono. Two things in ts_field_decl (kernel, resolve/fields.rs) hid the field req from the receiver lookup:
reqis declaredget req(): HonoRequest<P, I['out']>. Onlyreq: Tfields were read, so a getter never typed anything. Aget field(): Tline now types the field asT.- The class's constructor is
constructor(req: Request, ...). A plain parameter of that name was accepted as the field's declaration and, coming first, hid the getter. A parameter now declares the field only with a modifier (private req: T), or in a class that extends another and may hand it tosuper(the existingfield-chain-ownercase for an inherited field).
Measured on hono at the pinned commit against the compiler oracle used in the gap register (section 6.1):
| Before | After | |
|---|---|---|
calls edges | 1790 | 1864 |
| Oracle edges matched | 469 / 706 (0.664) | 472 / 706 (0.669) |
| Edges removed | 0 |
63 of the 74 added edges are in test files, which the oracle does not judge. Of the 11 in source files, 8 come from callers the oracle did not reach and 3 match the oracle on another overload line. No added edge contradicts the oracle where it reached the caller. Recall barely moves because the fork links header calls to the first overload signature (line 185) while the oracle keys the implementation (line 188), and the oracle credits a call to the outermost named function. zod's call edges are identical before and after.
Tests: a new case in js-family-receiver-fixes.test.ts (getter typed by its return type, a same-named plain constructor parameter, a getter with no return type declined, and a same-named method on another class not chosen). Full suite 687 files, 8760 tests passing; no golden dump changed.
Summary by CodeRabbit
- Bug Fixes
- Improved TypeScript method resolution for properties accessed through getters with declared return types.
- Corrected how constructor parameters are treated when resolving methods, including in classes with inheritance.
- Refined handling of unannotated getters, plain constructor parameters, and parameter properties to avoid incorrect method resolution.
- Tests
- Added regression coverage for getter-backed properties, including unannotated and object-literal getters, and for constructor parameters that share names with properties.