Deferred from PR #1314 review (Greptile P1).
Problem
In handlePropWriteTypeMap (src/extractors/javascript.ts), constructor property assignments like this.logger = new Logger(...) are stored in the typeMap as this.logger — without a class-scope qualifier.
When a single file defines two or more classes that both assign the same property name via this.prop = new DifferentCtor(), only the first write survives (setTypeMapEntry discards equal-confidence duplicates). Callers of the second class then resolve this.prop to the wrong type, producing spurious call graph edges.
Impact
- Before the PR that seeded this: neither edge was resolved (no false positive)
- After the PR: one class resolves correctly, the other incorrectly — a false positive
- The JS precision gate is at 1.0, so this will surface as a benchmark failure if a multi-class fixture exercises the pattern
Fix
Key the typeMap entry as ClassName.prop (e.g. Logger.logger) instead of this.prop, where ClassName is the class currently being walked. This requires passing the current class context to handlePropWriteTypeMap.
Example
class A {
constructor() { this.service = new ServiceA(); }
doA() { this.service.methodA(); } // should resolve to ServiceA.methodA
}
class B {
constructor() { this.service = new ServiceB(); }
doB() { this.service.methodB(); } // currently resolves to ServiceA.methodB (wrong!)
}
Deferred from PR #1314 review.
Deferred from PR #1314 review (Greptile P1).
Problem
In
handlePropWriteTypeMap(src/extractors/javascript.ts), constructor property assignments likethis.logger = new Logger(...)are stored in the typeMap asthis.logger— without a class-scope qualifier.When a single file defines two or more classes that both assign the same property name via
this.prop = new DifferentCtor(), only the first write survives (setTypeMapEntry discards equal-confidence duplicates). Callers of the second class then resolvethis.propto the wrong type, producing spurious call graph edges.Impact
Fix
Key the typeMap entry as
ClassName.prop(e.g.Logger.logger) instead ofthis.prop, where ClassName is the class currently being walked. This requires passing the current class context tohandlePropWriteTypeMap.Example
Deferred from PR #1314 review.