#13884: feat: Replace any types with proper TypeScript interfaces for better type safety
channel: discord
stale
Cluster:
Session Management and Fixes
This PR enhances type safety across multiple modules by replacing `any` types with proper TypeScript interfaces.
## ๐ Type Safety Improvements
### ๐ ๏ธ Tool Result Types (`get-reply-inline-actions.ts`)
- **Added `ToolResult` interface** for tool execution results
- **Added `ToolResultContentBlock` interface** for complex content structures
- **Replaced `result: any`** with proper typing and type guards
- **Removed oxlint disable comment** - no longer needed with proper types
- **Enhanced JSDoc documentation** for better developer experience
### ๐ฌ Discord Member Types (`sender-identity.ts`)
- **Added `DiscordMember` interface** to replace `member?: any`
- **Improved function signatures** with proper typing
- **Removed oxlint disable comments** for cleaner code
- **Better IDE support** with autocomplete and type checking
### ๐ Session Message Types (`session-memory/handler.ts`)
- **Added `SessionMessage` interface** for message structure
- **Added `MessageContentBlock` interface** for content blocks
- **Added `SessionEntry` interface** for session file entries
- **Replaced `any` type casting** with proper interfaces
- **Enhanced type safety** for message processing
## โจ Benefits
### ๐ Developer Experience
- **Better IDE support** with autocomplete and IntelliSense
- **Compile-time error detection** instead of runtime failures
- **Clear interfaces** document expected data structures
- **Improved maintainability** with self-documenting code
### ๐ก๏ธ Runtime Safety
- **Type guards** prevent invalid data from causing errors
- **Structured validation** replaces unsafe type assertions
- **Consistent typing** across related functions and modules
### ๐ Code Quality
- **Removed lint disable comments** - proper typing eliminates need
- **Enhanced documentation** with comprehensive JSDoc
- **Future-proof interfaces** that can be extended as needed
## ๐งช Compatibility
- โ
**Zero breaking changes** to public APIs
- โ
**Backwards compatible** with existing usage
- โ
**Runtime behavior unchanged** - only improves compile-time safety
- โ
**No performance impact** - interfaces compile away
## ๐ Files Modified
- `src/auto-reply/reply/get-reply-inline-actions.ts` - Tool result types
- `src/discord/monitor/sender-identity.ts` - Discord member types
- `src/hooks/bundled/session-memory/handler.ts` - Session message types
This improvement makes the codebase more robust and maintainable while providing better developer tooling support.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Replaced `any` types with proper TypeScript interfaces across three modules to improve type safety and developer experience. The changes introduce `ToolResult` and `ToolResultContentBlock` interfaces for tool execution results, `DiscordMember` interface for Discord member data, and `SessionMessage`/`MessageContentBlock`/`SessionEntry` interfaces for session memory structures. All interfaces follow consistent patterns with index signatures for extensibility.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with no functional changes or risks
- The changes are purely additive type improvements with no behavioral changes. All `any` types are replaced with appropriate interfaces that match the actual runtime data structures. The interfaces use index signatures for forward compatibility and the code maintains all existing runtime behavior.
- No files require special attention
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#21804: fix: improve type safety and use project runtime logging
by hobostay ยท 2026-02-20
81.3%
#13882: feat: Enhance session checkpoint system with better types and valid...
by trevorgordon981 ยท 2026-02-11
77.7%
#6039: fix: improve type safety in gateway registration
by Bharadwajreddy1406 ยท 2026-02-01
75.0%
#3647: fix: sanitize tool arguments in session history
by nhangen ยท 2026-01-29
74.4%
#12642: feat(tools): typed tool schemas for xAI/Grok compatibility
by 2nd-ren ยท 2026-02-09
74.2%
#23594: test(tui): fix mock typing in command handler tests
by Sashamine ยท 2026-02-22
74.1%
#19632: fix: suppressToolErrors now suppresses exec tool failure notifications
by Gitjay11 ยท 2026-02-18
73.8%
#3392: fix(hooks): remove debug console.log statements from session-memory...
by WinJayX ยท 2026-01-28
73.6%
#6819: fix(tui): handle unstructured tool results and errors in tool execu...
by TreyDong ยท 2026-02-02
73.6%
#21027: fix(tests): resolve TypeScript type errors in CLI test files
by kittipond2365 ยท 2026-02-19
73.6%