โ† Back to PRs

#13884: feat: Replace any types with proper TypeScript interfaces for better type safety

by trevorgordon981 open 2026-02-11 04:44 View on GitHub โ†’
channel: discord stale
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