Fix TypeScript lint issues: remove broad type casts, refactor test helpers, add user ID validation#77
Merged
warengonzaga merged 2 commits intodevfrom Oct 13, 2025
Merged
Conversation
Merged
…ctors, add user ID validation Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove broad 'as any' cast and update parameter properties
Fix TypeScript lint issues: remove broad type casts, refactor test helpers, add user ID validation
Oct 12, 2025
Member
|
@copilot what's the compatibility of this to |
Contributor
Author
This PR is fully compatible with the ✅ Clean merge: The changes merge cleanly into
The changes are ready to be merged into |
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 addresses three TypeScript linting issues to improve type safety and code quality:
as anytype cast in admin command testsChanges
1. Replace broad type cast in
adminCommands.test.tsThe test was using a broad
as anycast when mocking the Telegram API, which bypasses TypeScript's type checking:Now uses a minimal, typed interface that precisely defines only the
sendMessagemethod with its correct signature, maintaining type safety while still serving as an effective test mock.2. Refactor test helper classes in
commandRegistry.test.tsThe mock helper classes (
MockCommand,MockConversationProcessor,MockCallbackProcessor) were using TypeScript parameter property shorthand, which triggeredno-unused-varslint warnings:Now declares properties explicitly on the class and assigns them in the constructor body, eliminating lint warnings while preserving the same behavior.
3. Add user ID validation in
emailManager.tsThe
updateUserEmailfunction now validates user IDs before processing, preventing potential issues with invalid inputs:This validation:
null,undefined,NaN, non-integer, or non-positive valuesenhancedEmailManager.test.tsTesting
Impact
These changes improve code quality with zero behavioral changes to existing functionality. Type safety is enhanced while maintaining full backward compatibility.
Original prompt
Created from VS Code via the GitHub Pull Request extension.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.