Skip to content

fix(lint): no-explicit any for api/chat#827

Merged
CodeWithCJ merged 1 commit intoCodeWithCJ:mainfrom
Sim-sat:no-explicit-any-chat
Mar 3, 2026
Merged

fix(lint): no-explicit any for api/chat#827
CodeWithCJ merged 1 commit intoCodeWithCJ:mainfrom
Sim-sat:no-explicit-any-chat

Conversation

@Sim-sat
Copy link
Copy Markdown
Contributor

@Sim-sat Sim-sat commented Mar 3, 2026

Description

Removes explicit anys from api/chat.

Related Issue

PR type [ ] Issue [x] New Feature [ ] Documentation
Linked Issue: #795

Checklist

Please check all that apply:

  • [MANDATORY for new feature] Alignment: I have raised a GitHub issue and it was reviewed/approved by maintainers
  • Tests: I have included automated tests for my changes.
  • [MANDATORY for UI changes] Screenshots: I have attached "Before" vs "After" screenshots below.
  • [MANDATORY for Frontend changes] Quality: I have run pnpm run validate (especially for Frontend).
  • Translations: I have only updated the English (en) translation file (if applicable).
  • Architecture: My code follows the existing architecture standards.
  • Database Security: I have updated rls_policies.sql for any new user-specific tables.
  • [MANDATORY - ALL] Integrity & License: I certify this is my own work, free of malicious code(phishing, malware, etc.) and I agree to the License terms.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on improving the type safety and code clarity within the api/chat directory by removing explicit any types and introducing specific interface definitions for various data structures. This change enhances the maintainability and reduces the risk of runtime errors in the chatbot API functions.

Highlights

  • Explicit any Removal: This PR eliminates the use of explicit any types in the api/chat directory, enhancing type safety and code maintainability.
  • Interface Definitions: Introduced specific interface definitions for data structures used in chatbot API functions, such as ExerciseInput, FoodInput, MeasurementInputData, and WaterInput.
  • Type Safety: Replaced instances of any with more specific types like MessageMetadata, CheckInPayload, and ApiError to provide better type checking and reduce potential runtime errors.
Changelog
  • SparkyFitnessFrontend/src/api/Chatbot/Chatbot_ExerciseHandler.ts
    • Replaced inline type definition with ExerciseInput interface for the data parameter in processExerciseInput function.
  • SparkyFitnessFrontend/src/api/Chatbot/Chatbot_FoodHandler.ts
    • Replaced inline type definition with FoodInput interface for the data parameter in processFoodInput function.
    • Replaced any type with MessageMetadata type for originalMetadata parameter in addFoodOption function.
  • SparkyFitnessFrontend/src/api/Chatbot/Chatbot_MeasurementHandler.ts
    • Introduced interfaces CheckInPayload, MeasurementItem, MeasurementInputData, and ApiError to replace any types.
    • Replaced any type with CheckInPayload in upsertCheckInMeasurement function.
    • Replaced any type with MeasurementInputData in processMeasurementInput function.
    • Replaced any type with CheckInPayload for updateData variable within processMeasurementInput.
    • Replaced any type with ApiError for categorySearchError and categoryCreateError variables.
    • Replaced any type with ApiError for customEntryError variable.
  • SparkyFitnessFrontend/src/api/Chatbot/Chatbot_WaterHandler.ts
    • Replaced inline type definition with WaterInput interface for the data parameter in processWaterInput function.
  • SparkyFitnessFrontend/src/api/Chatbot/sparkyChatService.ts
    • Imported and used FoodInput, ExerciseInput, MeasurementInputData, and WaterInput interfaces.
    • Added interfaces ChatHistory, BaseAIResponse, LogFoodIntent, LogExerciseIntent, LogMeasurementIntent, LogWaterIntent, ChatIntent, ParsedAIResponse, MessagesToSend, and MessageContent.
    • Specified ChatHistory[] type for the data variable in loadChatHistory function.
    • Replaced any type with MessageMetadata in saveMessageToHistory function.
    • Replaced any type with MessageMetadata in processUserInput function.
    • Replaced inline type definition with ParsedAIResponse interface for parsedResponse variable in processUserInput function.
    • Specified MessagesToSend[] type for messagesToSend variable in getAIResponse function.
    • Specified MessageContent[] type for userMessageContent variable in getAIResponse function.
    • Specified RawFoodOption type for rawOption parameter in callAIForFoodOptions function.
  • SparkyFitnessFrontend/src/types/Chatbot_types.ts
    • Added RawFoodOption and MessageMetadata interfaces.
    • Replaced any type with MessageMetadata in Message interface.
Activity
  • The PR addresses issue Eslint errors in Frontend #795 related to removing explicit any types.
  • Automated tests are included to validate the changes.
  • Frontend quality has been validated using pnpm run validate.
  • The code adheres to existing architecture standards.
  • The changes are certified to be free of malicious code and comply with the license terms.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces type safety and improves code clarity within the chatbot feature by defining specific interfaces for input data used in processFoodInput, processExerciseInput, processMeasurementInput, and processWaterInput functions. It replaces the previous any type annotations with these new interfaces, enhancing type checking and reducing potential runtime errors. Additionally, the pull request updates the saveMessageToHistory function to use the MessageMetadata type for metadata. It also refactors the callAIForFoodOptions function to directly pass rawOption.serving_size to parseFloat instead of calling .toString() on it first.

Comment thread SparkyFitnessFrontend/src/api/Chatbot/sparkyChatService.ts
@CodeWithCJ CodeWithCJ merged commit 70d770d into CodeWithCJ:main Mar 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants