Skip to content

Commit 7c4e684

Browse files
authored
refactor: eliminate all any types and consolidate type definitions (#46)
* refactor: eliminate all any types and consolidate type definitions - 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 * fix pr comments * feat: enhance AngularAnalyzer with new IndexChunk interface and refactor 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. * fix linting
1 parent d28460c commit 7c4e684

File tree

21 files changed

+533
-250
lines changed

21 files changed

+533
-250
lines changed

AGENTS.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ These are non-negotiable. Every PR, feature, and design decision must respect th
2222
- **Never stage/commit `.planning/**`\*\* (or any other local workflow artifacts) unless the user explicitly asks in that message.
2323
- **Never use `gsd-tools ... commit` wrappers** in this repo. Use plain `git add <exact files>` and `git commit -m "..."`.
2424
- **Before every commit:** run `git status --short` and confirm staged files match intent; abort if any `.planning/**` is staged.
25-
- **Avoid using `any` Type AT ALL COSTS.
25+
- \*\*Avoid using `any` Type AT ALL COSTS.
26+
2627
## Evaluation Integrity (NON-NEGOTIABLE)
2728

2829
These rules prevent metric gaming, overfitting, and false quality claims. Violation of these rules means the feature CANNOT ship.
@@ -128,6 +129,11 @@ If an agent has to call the tool twice to understand the response, the tool fail
128129
- `src/core/` is framework-agnostic. No hardcoded framework strings (Angular, React, Vue, etc.).
129130
- CLI code belongs in `src/cli.ts`. Never in `src/index.ts`.
130131
- Framework analyzers self-register their own patterns (e.g., Angular computed+effect pairing belongs in the Angular analyzer, not protocol layer).
132+
- **Types and interfaces must be framework-agnostic in core and shared utilities.**
133+
Framework-specific field names (Angular-only, React-only, etc.) belong exclusively in their
134+
respective analyzer files under `src/analyzers/`. Never add named framework-specific fields
135+
to interfaces in `src/types/`, `src/utils/`, or `src/core/`.
136+
Use `Record<string, T>` for open-ended data that frameworks extend at runtime.
131137

132138
### Release Checklist
133139

@@ -153,6 +159,3 @@ These came from behavioral observation across multiple sessions. They're here so
153159
See `internal-docs/AGENTS.md` for internal-only guidelines and context.
154160

155161
---
156-
157-
**Current focus:** See `internal-docs/ISSUES.md` for active release blockers.
158-
For full project history and context handover, see `internal-docs/ARCHIVE/WALKTHROUGH-v1.6.1.md`.

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@
3939
### Added
4040

4141
- **Definition-first ranking**: Exact-name searches now show the file that *defines* a symbol before files that use it. For example, searching `parseConfig` shows the function definition first, then callers.
42+
43+
### Refactored
44+
45+
- **Eliminated all `any` types**: 68 occurrences across 15 files now use proper TypeScript types. Replaced unsafe `Record<string, any>` with `Record<string, unknown>` and narrowed types using proper type guards. Promoted `@typescript-eslint/no-explicit-any` from `warn` to `error` to enforce strict typing.
46+
- **Consolidated duplicate type definitions**: Single source of truth for shared types:
47+
- `PatternTrend` canonical location in `types/index.ts` (imported by `usage-tracker.ts`)
48+
- New `PatternCandidateBase` for shared pattern fields; `PatternCandidate extends PatternCandidateBase`; runtime adds optional internal fields
49+
- New `UsageLocation` base for both `ImportUsage` and `SymbolUsage` (extends with `preview` field)
50+
- `GoldenFile extends IntelligenceGoldenFile` to eliminate field duplication (`file`, `score`)
51+
- Introduced `RuntimePatternPrimary` and `DecisionCard` types for tool-specific outputs
4252
- **Scope headers in code snippets**: When requesting snippets (`includeSnippets: true`), each code block now starts with a comment like `// UserService.login()` so agents know where the code lives without extra file reads.
4353
- **Edit decision card**: When searching with `intent="edit"`, `intent="refactor"`, or `intent="migrate"`, results now include a decision card telling you whether there's enough evidence to proceed safely. The card shows: whether you're ready (`ready: true/false`), what to do next if not (`nextAction`), relevant team patterns to follow, a top example file, how many callers appear in results (`impact.coverage`), and what searches would help close gaps (`whatWouldHelp`).
4454
- **Caller coverage tracking**: The decision card shows how many of a symbol's callers are in your search results. Low coverage (less than 40% when there are lots of callers) triggers an alert so you know to search more before editing.

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default tseslint.config(
1616
// import plugin is handled via recommended usually, but kept simple for now
1717
},
1818
rules: {
19-
'@typescript-eslint/no-explicit-any': 'warn',
19+
'@typescript-eslint/no-explicit-any': 'error',
2020
'@typescript-eslint/no-unused-vars': ['error', { 'argsIgnorePattern': '^_', 'varsIgnorePattern': '^_', 'caughtErrorsIgnorePattern': '^_' }],
2121
'no-console': ['warn', { 'allow': ['warn', 'error'] }],
2222
},

0 commit comments

Comments
 (0)