refactor: eliminate all any types and consolidate type definitions#46
Merged
PatrickSys merged 4 commits intomasterfrom Feb 22, 2026
Merged
refactor: eliminate all any types and consolidate type definitions#46PatrickSys merged 4 commits intomasterfrom
PatrickSys merged 4 commits intomasterfrom
Conversation
- Remove 68 `any` occurrences across 15 files with proper TypeScript types - Replace `Record<string, any>` with `Record<string, unknown>` for JSON - Add type guards and narrowing for unsafe external data - Promote @typescript-eslint/no-explicit-any from warn to error - Consolidate duplicate types: PatternTrend, PatternCandidateBase, UsageLocation - Make GoldenFile extend IntelligenceGoldenFile to eliminate field duplication - Define PatternCandidateBase for shared pattern candidate fields - Create UsageLocation base for ImportUsage and SymbolUsage - All 234 tests passing, type-check clean, 0 lint errors
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Greptile SummaryComprehensive elimination of
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| src/types/index.ts | Core type consolidation: adds UsageLocation, PatternTrend, PatternCandidateBase, PatternCandidate, PatternEntry, PatternsData, IntelligenceGoldenFile, IntelligenceData. Replaces all Record<string, any> with Record<string, unknown>. Well-structured type hierarchy. |
| src/analyzers/angular/index.ts | Major refactoring from any to proper TSESTree types for AST node handling. Adds AngularInput/AngularOutput interfaces. Some inline as casts for callee shapes are pragmatic but slightly loose. Overall significant improvement in type safety. |
| src/core/indexer.ts | Replaces any with IntelligenceData, Dependency, ArchitecturalLayer. Contains a type-unsafe as GoldenFile['patterns'] cast at line 585 — dynamic Record<string, boolean> keys don't match the fixed GoldenFile.patterns shape. |
| src/core/reranker.ts | Replaces module-level any with CrossEncoderTokenizer and CrossEncoderModel interfaces. Adds proper null check before using cached model/tokenizer. Clean improvement. |
| src/embeddings/transformers.ts | Replaces any pipeline with FeatureExtractionPipelineType. Adds proper null checks before pipeline usage. Pipeline cast is well-documented with TS2590 justification. |
| src/storage/lancedb.ts | Replaces any with proper LanceDB Connection/Table types and LanceDBRecord interface. Adds null checks for db before operations. Well-structured refactoring. |
| src/tools/search-codebase.ts | Largest file change. Moves DecisionCard to types.ts, uses IntelligenceData/PatternsData throughout. Adds RelationshipsData interface. Properly types args destructuring. Uses ChunkMetadata for scope helpers. |
| src/utils/usage-tracker.ts | Consolidates PatternTrend (re-exports from types/index.ts), uses PatternCandidateBase, IntelligenceGoldenFile, UsageLocation. ImportUsage is now a type alias. GoldenFile extends IntelligenceGoldenFile. |
| eslint.config.js | Promotes no-explicit-any from warn to error. Prevents regression. |
Class Diagram
%%{init: {'theme': 'neutral'}}%%
classDiagram
class UsageLocation {
+string file
+number line
}
class PatternCandidateBase {
+string name
+string frequency
+PatternTrend trend
+string guidance
+string newestFileDate
}
class PatternCandidate {
+object canonicalExample
+number count
}
class PatternEntry {
+PatternCandidate primary
+PatternCandidate[] alsoDetected
}
class IntelligenceGoldenFile {
+string file
+number score
}
class GoldenFile {
+object patterns
}
class IntelligenceData {
+PatternsData patterns
+IntelligenceGoldenFile[] goldenFiles
+object internalFileGraph
+string generatedAt
}
class ImportUsage {
<<type alias>>
}
class SymbolUsage {
+string preview
}
class RuntimePatternPrimary {
+number count
+string[] examples
}
PatternCandidateBase <|-- PatternCandidate : extends
PatternCandidateBase <|-- RuntimePatternPrimary : extends
IntelligenceGoldenFile <|-- GoldenFile : extends
UsageLocation <|-- SymbolUsage : extends
UsageLocation <.. ImportUsage : alias
PatternEntry o-- PatternCandidate : primary / alsoDetected
IntelligenceData o-- PatternEntry : patterns map
IntelligenceData o-- IntelligenceGoldenFile : goldenFiles
Last reviewed commit: 1b507bf
…tor signal input/output handling - Introduced IndexChunk interface for better type definition of chunk properties. - Refactored signal input() and output() handling to improve clarity and type safety. - Simplified logic for determining required properties in signal-based inputs and outputs. - Updated type assertions to leverage the new IndexChunk interface for chunk processing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR completes a comprehensive refactoring to eliminate unsafe TypeScript typing and consolidate duplicate type definitions:
anyoccurrences eliminated across 15 files — replaced with proper types (unknown, specific interfaces, type guards)PatternTrend,PatternCandidateBase,UsageLocation, andGoldenFileChanges
Type Safety
Record<string, any>withRecord<string, unknown>throughout JSON-parsed data@typescript-eslint/typescript-estreefor AST node handlingChunkMetadataindex signature fromanytounknownType Consolidation
types/index.ts, imported byusage-tracker.tsPatternCandidate extends PatternCandidateBaseImportUsage(alias) andSymbolUsage(extends)IntelligenceGoldenFileto eliminatefile/scoreduplicationESLint Enforcement
@typescript-eslint/no-explicit-anyfromwarntoerroranyviolationsTest Plan
✅ Type check:
pnpm type-check— 0 errors✅ Unit tests:
pnpm test— 234/234 passing✅ Linting:
pnpm lint— 0 errors (33 pre-existing console.log warnings in tests)Fixes: Eliminates technical debt from initial
anyusage, prevents future unsafe typing.