fix(extraction): extract type refs from TS interface property and method signatures (#432)

Types that appeared only in TypeScript interface members — property
signatures like `value?: Partial<IPage>` and method signatures like
`fetchPage(arg: IPage): IOrderField` — were not being captured at
extraction time, so the resolver never built `references` edges for
them. `codegraph_impact`/`codegraph_callers` on the named type missed
every consumer that imported it solely to use it in an interface shape.

Add a `property_signature` / `method_signature` branch in `visitNode`:
when inside a class-like node (which covers interfaces) and the
language supports type annotations, call `extractTypeAnnotations` with
the parent (interface) node ID as the edge source. No property/method
node is created — only unresolved references that the resolver wires
the same way it wires field and parameter type references elsewhere.
This commit is contained in:
TheSunn
2026-05-26 17:01:45 -05:00
committed by GitHub
parent 2543ae565a
commit 7e0d9b9ec0
3 changed files with 58 additions and 0 deletions
+32
View File
@@ -205,6 +205,38 @@ export interface User {
});
});
it('should extract type references from interface property signatures', () => {
const code = `
import type { IPage } from '../PromoterList';
import type { IOrderField } from '../types';
interface Hprops {
value?: Partial<IPage> & Partial<IOrderField>;
}
`;
const result = extractFromSource('HeaderFilter.ts', code);
const refs = result.unresolvedReferences.filter((r) => r.referenceKind === 'references');
expect(refs.some((r) => r.referenceName === 'IPage')).toBe(true);
expect(refs.some((r) => r.referenceName === 'IOrderField')).toBe(true);
});
it('should extract type references from interface method signatures', () => {
const code = `
import type { IPage } from '../PromoterList';
import type { IOrderField } from '../types';
interface MethodForm {
fetchPage(arg: IPage): IOrderField;
}
`;
const result = extractFromSource('MethodForm.ts', code);
const refs = result.unresolvedReferences.filter((r) => r.referenceKind === 'references');
expect(refs.some((r) => r.referenceName === 'IPage')).toBe(true);
expect(refs.some((r) => r.referenceName === 'IOrderField')).toBe(true);
});
it('should track function calls', () => {
const code = `
function main() {