feat(types): migrate remaining leaf modules to TypeScript#566
feat(types): migrate remaining leaf modules to TypeScript#566carlos-alm merged 6 commits intomainfrom
Conversation
Migrate 8 leaf modules from JavaScript to TypeScript: - shared/constants, file-utils, generators, hierarchy - infrastructure/config, native, registry, update-check Add full type annotations, export RepoListEntry for declaration emit, add missing mcp defaults (implementations, interfaces), and expand community config type to match DEFAULTS. Impact: 96 functions changed, 218 affected
|
Claude finished @carlos-alm's task —— View job TypeScript Migration Review ⭐⭐⭐⭐Reviewing the migration of 8 remaining leaf modules to TypeScript... Todo List
Phase 1: Root Cause Analysis ✅Problem Being Solved: This PR completes the TypeScript migration effort for the remaining 8 leaf modules that were left from previous migration phases. This addresses type safety, better IDE support, and reduces the maintenance burden of maintaining both JS and TS files in the same codebase. Migration Scope: 8 leaf modules migrated from Risk Assessment: LOW - These are utility modules with well-defined interfaces. Clean file renames with type additions. Phase 2: Configuration Change Detection ✅✅ GOOD: No configuration files were modified (biome.json, tsconfig.json, package.json scripts remain unchanged) Configuration Analysis: Clean migration with zero rule relaxations or configuration modifications. This indicates the migration was done properly without needing to silence warnings. Phase 3: Test Integrity ✅✅ GOOD: No test files were modified in this commit Test Analysis: No evidence of test manipulation or weakened assertions. The migration maintains all existing functionality. Phase 4: Code Quality Assessment ✅✅ EXCELLENT: Comprehensive interface definitions added for all major functions Key Quality Observations:
Phase 5: Backlog Compliance GradingZero-dep: ✅ PASS - No new runtime dependencies added, builds on existing tree-sitter/SQLite infrastructure Tier: 1 (zero-dep ✅ + foundation-aligned ✅) Root Cause AnalysisProblem Being Solved: Complete TypeScript migration of remaining leaf modules to achieve codebase consistency and improved type safety Backlog Compliance
Critical ConcernsNone identified. This is a high-quality TypeScript migration. Final Recommendation
|
Greptile SummaryThis PR completes the TypeScript migration for 8 remaining leaf modules across Key changes and observations:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[loadConfig cwd] --> B{Cache hit?}
B -- yes --> C[Return structuredClone]
B -- no --> D{Config file found?}
D -- yes --> E[JSON.parse file]
E --> F[mergeConfig DEFAULTS + userConfig]
F --> G[applyEnvOverrides]
G --> H[resolveSecrets]
H --> I[Cache and return]
D -- no --> J[applyEnvOverrides on DEFAULTS]
J --> H
subgraph TypeSafety
K[DEFAULTS satisfies CodegraphConfig]
L[CodegraphConfig interface in types.ts]
K --> L
end
subgraph MigratedModules
N[shared/constants.ts]
O[shared/file-utils.ts]
P[shared/generators.ts]
Q[shared/hierarchy.ts]
R[infrastructure/native.ts]
S[infrastructure/registry.ts]
T[infrastructure/update-check.ts]
end
|
- Type loadNative()/getNative() with NativeAddon interface instead of bare object - Coerce null to undefined for readSourceRange end_line parameter - Add index signature to McpDefaults for Record<string, number> compatibility Impact: 3 functions changed, 3 affected
The object return type caused TS2339 errors in resolve.ts and parser.ts where properties like resolveImport, computeConfidence, resolveImports, and ParseTreeCache were accessed on the returned value.
readSourceRange expects number | undefined but c.end_line can be number | null | undefined. Use nullish coalescing to convert.
McpDefaults interface lacks an index signature, so it cannot be passed directly to initMcpDefaults which expects Record<string, number>. Spreading creates a plain object with the index signature.
…to fix/review-566-ts-types
Summary
shared/constants,shared/file-utils,shared/generators,shared/hierarchy,infrastructure/config,infrastructure/native,infrastructure/registry,infrastructure/update-checkRepoListEntryfor declaration emit, add missing MCP defaults (implementations,interfaces), expandCodegraphConfig.communitytype to include all DEFAULTS fieldsCodegraphConfigfromconfig.tsviatypes.tsfor consistent type usage across the codebaseTest plan
resolve.ts,parser.ts,context.ts,server.ts)npm run buildsucceeds