compound-engineering-plugin icon indicating copy to clipboard operation
compound-engineering-plugin copied to clipboard

[compounding-engineering] Bug: TypeScript compilation errors after refactoring

Open lmichaelwar opened this issue 1 year ago • 1 comments

Bug Report: TypeScript Compilation Errors After Refactoring

Bug Description

Component: Build System - TypeScript compilation Summary: TypeScript compilation failed with 10 errors after code refactoring due to function callback this context issues

Environment

  • Plugin Version: compounding-engineering plugin
  • Claude Code Version: CLI version unknown
  • OS: Linux pwb 6.14.0-1017-gcp #18~24.04.1-Ubuntu SMP Tue Sep 23 17:51:44 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

What Happened

When running npm run build, TypeScript compilation failed with 10 errors related to:

  • Parameter 'addr' implicitly has an 'any' type (line 363)
  • 'this' implicitly has type 'any' because it does not have a type annotation (lines 364, 365)
  • Parameter 'config' implicitly has an 'any' type (line 1865)
  • Parameter 'address' implicitly has an 'any' type (line 1865)
  • Multiple 'this' context issues in forEach callbacks

The errors occurred after recent refactoring changes to the dex-impact-predictor.ts file.

Expected Behavior

npm run build should complete successfully without TypeScript compilation errors.

Steps to Reproduce

  1. Run npm run build after recent code changes
  2. TypeScript compiler throws 10 errors related to function callbacks and this context
  3. Build process exits with error code 2

Error Messages

src/dex-impact-predictor.ts:363:64 - error TS7006: Parameter 'addr' implicitly has an 'any' type.

363         const staleOrMissing = uniqueAddresses.filter(function(addr) {
                                                                   ~~~~

src/dex-impact-predictor.ts:364:27 - error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.

364             const entry = this.poolAccountCache.get(addr);
                              ~~~~

src/dex-impact-predictor.ts:365:55 - error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.

365             return !entry || (now - entry.timestamp > this.CACHE_TTL);
                                                          ~~~~

src/dex-impact-predictor.ts:1865:45 - error TS7006: Parameter 'config' implicitly has an 'any' type.

1865         this.poolConfigMap.forEach(function(config, address) {
                                                 ~~~~~~

[Additional similar errors...]

Root Cause

The refactoring process introduced function() callbacks instead of arrow functions, causing:

  1. Loss of this context in class methods
  2. Implicit any types for callback parameters
  3. .bind(this) calls that weren't properly cleaned up

Resolution

Fixed by converting function() callbacks to arrow functions:

  • Changed function(addr) to (addr)
  • Changed function(config, address) to (config, address)
  • Removed unnecessary .bind(this) calls

Additional Context

This bug was introduced during the comprehensive code review and refactoring process that addressed multiple security vulnerabilities and performance issues. The refactoring successfully improved code quality and maintainability but introduced these TypeScript compilation issues that needed immediate resolution.


Reported via /report-bug command

lmichaelwar avatar Nov 29 '25 20:11 lmichaelwar

Sorry, this was not meant to be a bug report to you, it was over my own codebase. Plase disregard!

lmichaelwar avatar Nov 29 '25 20:11 lmichaelwar