-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TypeScript] More specific types on budget table components #4524
base: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
WalkthroughThis pull request updates several type definitions across multiple components in the desktop client. The changes replace manually defined and generic types with specific types derived from the Possibly related PRs
Suggested reviewers
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Bundle Stats — desktop-clientHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller
Unchanged
|
Bundle Stats — loot-coreHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset No files were changed View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/desktop-client/src/components/budget/SidebarCategory.tsx (1)
35-35
: Improved type safety with CategoryEntity ID usage.The change from
string
toCategoryEntity['id']
makes the code more type-safe by ensuring that only valid category IDs can be passed to this function.This is a good improvement that enforces type safety. The function signature now explicitly states that it expects a category ID from a CategoryEntity, making the code more self-documenting and preventing potential type mismatches.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
upcoming-release-notes/4524.md
is excluded by!**/*.md
📒 Files selected for processing (6)
packages/desktop-client/src/components/budget/IncomeCategory.tsx
(1 hunks)packages/desktop-client/src/components/budget/IncomeGroup.tsx
(1 hunks)packages/desktop-client/src/components/budget/SidebarCategory.tsx
(1 hunks)packages/desktop-client/src/components/budget/SidebarGroup.tsx
(3 hunks)packages/desktop-client/src/components/budget/envelope/EnvelopeBudgetComponents.tsx
(4 hunks)packages/desktop-client/src/components/budget/tracking/TrackingBudgetComponents.tsx
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: build (macos-latest)
- GitHub Check: build (windows-latest)
- GitHub Check: build (ubuntu-latest)
- GitHub Check: Wait for Netlify build to finish
- GitHub Check: Analyze
🔇 Additional comments (23)
packages/desktop-client/src/components/budget/SidebarCategory.tsx (1)
37-37
: Appropriate type narrowing for Promise-based deletion.Using
CategoryEntity['id']
instead ofstring
enhances type safety for this asynchronous operation.This change correctly aligns the parameter type with its usage. Since the component receives a
category
prop of typeCategoryEntity
, ensuring that all functions using its ID are properly typed improves consistency and prevents potential errors.packages/desktop-client/src/components/budget/IncomeCategory.tsx (3)
21-21
: Type refinement improves object property safety.The
editingCell
property now correctly usesCategoryEntity['id']
for itsid
field, ensuring type consistency across the component.This provides stronger type guarantees when checking if a cell is being edited, making the code more robust against type-related bugs.
24-24
: Enhanced type safety for month editing operations.The
onEditMonth
callback type signature now properly uses the specific category ID type.This change ensures that the function is called with the correct ID type, which is especially important when propagating events up through the component hierarchy.
30-30
: Proper typing for activity tracking function.Using the proper category ID type for
onShowActivity
improves type safety.This change ensures that only legitimate category IDs can be passed to the activity tracking functionality, preventing potential runtime errors due to type mismatches.
packages/desktop-client/src/components/budget/tracking/TrackingBudgetComponents.tsx (5)
22-25
: Proper type imports enhance component type safety.Adding explicit imports for CategoryEntity and CategoryGroupEntity types provides a foundation for more specific type definitions throughout the file.
These imports are a key part of the PR's goal to improve type specificity in budget table components, enabling the subsequent type improvements.
141-141
: Added explicit type for the group property.Changing from an inline object type to
CategoryGroupEntity
provides a more robust and maintainable type definition.Using the imported type instead of an inline definition ensures type consistency across the codebase and provides better type checking and IDE support.
201-201
: Type-specific category definition.Replacing an inline object type with
CategoryEntity
improves type safety and documentation.This change ensures that the component receives a properly typed category object with all the expected properties, making the code more maintainable and less prone to errors.
203-203
: Enhanced function signature for editing.The
onEdit
callback now uses the more specificCategoryEntity['id']
type for the id parameter.This properly constrains the types of values that can be passed to this function, aligning with how it's used throughout the component.
205-205
: Type-safe activity tracking.The
onShowActivity
function now explicitly requires aCategoryEntity['id']
rather than any string.This improvement ensures that only valid category IDs can be used to show activity, preventing potential runtime errors.
packages/desktop-client/src/components/budget/envelope/EnvelopeBudgetComponents.tsx (7)
20-23
: Added structured type imports for budget entities.Importing the specific entity types from the models module provides a foundation for better type safety throughout the file.
These imports enable the type enhancements found throughout the rest of the file, bringing consistency with the project's type system.
138-138
: Enhanced group property type definition.Using
CategoryGroupEntity
instead of an inline type improves type safety and consistency.This change ensures the component properly handles group objects with all the expected properties defined in the centralized type definition.
196-196
: Improved category property typing.Replacing an inline object type with
CategoryEntity
enhances type checking and documentation.This change ensures that the component expects a properly structured category object, making the code more robust against potential type errors.
198-198
: Type-safe editing function signature.The
onEdit
callback now correctly usesCategoryEntity['id']
for the ID parameter.This ensures type consistency when editing categories, preventing potential type mismatches between the expected and actual parameter types.
200-200
: Type-specific activity tracking.The
onShowActivity
function now requires a properly typed category ID.This change improves type safety by ensuring that only valid category IDs can be used to trigger activity displays.
490-490
: Enhanced income category property typing.Using the
CategoryEntity
type for the category property inIncomeCategoryMonthProps
improves type safety.This change ensures consistent typing across all components that deal with categories, making the code more maintainable.
493-493
: Type-safe activity tracking for income categories.The
onShowActivity
function signature now properly usesCategoryEntity['id']
.This change improves type safety and maintains consistency with the other component types in the file.
packages/desktop-client/src/components/budget/IncomeGroup.tsx (3)
4-5
: Good modular type import!The addition of the
CategoryGroupEntity
type import from the central models file promotes type consistency across the codebase.
13-14
: Great type enhancement for improved type safety!Replacing the manually defined structure with the
CategoryGroupEntity
type eliminates potential inconsistencies and ensures the component respects the canonical type definition. The change to theeditingCell
property properly uses indexed access typeCategoryGroupEntity['id']
to ensure type coherence between the ID and the entity itself.
17-21
: Consistent parameter typing across callbacks!The function signatures now properly leverage
CategoryGroupEntity['id']
for all ID-related parameters and the completeCategoryGroupEntity
type for theonSave
callback. This ensures type safety throughout all interactions with category groups.packages/desktop-client/src/components/budget/SidebarGroup.tsx (4)
12-16
: Well-structured type imports!The import statement correctly uses the
type
keyword for TypeScript type-only imports, which is a best practice as it prevents type definitions from being included in the runtime bundle.
26-27
: Excellent type enhancement!Replacing the manually defined structure with the
CategoryGroupEntity
type improves type safety and maintainability by ensuring the component adheres to the canonical type definition.
32-41
: Comprehensive callback type refinement!All callback functions now properly use the specific entity ID types:
onEdit
,onDelete
, andonToggleCollapse
correctly useCategoryGroupEntity['id']
onSave
accepts the completeCategoryGroupEntity
objectonApplyBudgetTemplatesInGroup
properly uses an array ofCategoryEntity['id']
onShowNewCategory
correctly usesCategoryGroupEntity['id']
This approach ensures type safety and consistency across all callback interactions.
141-142
: Type-safe category ID mapping!The implementation correctly maps category IDs using the properly typed entity structure, maintaining type safety throughout the component's logic.
#1483