Skip to content
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

Fix send types in a number of places (2/2) #4147

Merged
merged 3 commits into from
Jan 20, 2025

Conversation

jfdoming
Copy link
Contributor

In #4145 I'm attempting to remove any types from the send function. In doing so I uncovered a bunch of places where types were set incorrectly. This PR cleans up those types (split into 2 for readability).

@actual-github-bot actual-github-bot bot changed the title Fix send types in a number of places (2/2) [WIP] Fix send types in a number of places (2/2) Jan 14, 2025
Copy link

netlify bot commented Jan 14, 2025

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 6b43e75
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/678b24d833b4ec000816ca80
😎 Deploy Preview https://deploy-preview-4147.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jfdoming jfdoming force-pushed the jfdoming/fix-send-types-2 branch from c0e93e7 to 906b6cc Compare January 14, 2025 06:04
Copy link
Contributor

github-actions bot commented Jan 14, 2025

Bundle Stats — desktop-client

Hey 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

Files count Total bundle size % Changed
14 6.5 MB → 6.5 MB (+136 B) +0.00%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/client/data-hooks/transactions.ts 📈 +30 B (+0.50%) 5.87 kB → 5.9 kB
home/runner/work/actual/actual/packages/loot-core/src/client/actions/prefs.ts 📈 +6 B (+0.36%) 1.64 kB → 1.64 kB
src/components/accounts/Account.tsx 📈 +103 B (+0.22%) 46.12 kB → 46.22 kB
src/components/reports/Overview.tsx 📈 +5 B (+0.03%) 14.8 kB → 14.8 kB
src/components/modals/EditUser.tsx 📉 -8 B (-0.06%) 13.39 kB → 13.38 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/wide.js 101.2 kB → 101.3 kB (+103 B) +0.10%
static/js/index.js 4.21 MB → 4.21 MB (+28 B) +0.00%
static/js/ReportRouter.js 1.59 MB → 1.59 MB (+5 B) +0.00%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/en-GB.js 97.12 kB 0%
static/js/en.js 97.13 kB 0%
static/js/workbox-window.prod.es5.js 5.69 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/pt-BR.js 48 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/uk.js 119.92 kB 0%
static/js/useAccountPreviewTransactions.js 1.63 kB 0%
static/js/AppliedFilters.js 10.21 kB 0%
static/js/narrow.js 84.68 kB 0%

Copy link
Contributor

github-actions bot commented Jan 14, 2025

Bundle Stats — loot-core

Hey 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

Files count Total bundle size % Changed
1 1.33 MB → 1.33 MB (+12 B) +0.00%
Changeset
File Δ Size
packages/loot-core/src/server/schedules/app.ts 📈 +24 B (+0.15%) 15.73 kB → 15.75 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
kcab.worker.js 1.33 MB → 1.33 MB (+12 B) +0.00%

Smaller

No assets were smaller

Unchanged

No assets were unchanged

@jfdoming jfdoming force-pushed the jfdoming/fix-send-types-2 branch 2 times, most recently from 2635ba5 to b4e38d5 Compare January 14, 2025 06:07
@jfdoming jfdoming changed the title [WIP] Fix send types in a number of places (2/2) Fix send types in a number of places (2/2) Jan 14, 2025
Copy link
Contributor

coderabbitai bot commented Jan 14, 2025

Walkthrough

This pull request introduces a series of type safety and error handling improvements across multiple files in the CodeRabbit project. The changes span various components and modules, focusing on enhancing method signatures, refining error handling, and improving type definitions. Key modifications include updating return types in interfaces like AdminHandlers, RulesHandlers, and SchedulesHandlers, adding more precise type annotations, and implementing more robust error checking mechanisms. The changes affect areas such as accounts, schedules, transactions, and server handlers, with a consistent theme of making the codebase more type-safe and resilient to potential runtime errors.

Possibly related PRs

Suggested labels

type-safety, error-handling, typescript-migration, code-quality

Suggested reviewers

  • youngcw
  • joel-jeremy

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
packages/loot-core/src/server/dashboard/types/handlers.d.ts (1)

20-22: Consider simplifying the union type.

While the current type is correct, it could be simplified to reduce redundancy. Consider this alternative:

type DashboardImportResult =
  | { status: 'ok' }
  | { error: 'json-parse-error' | 'internal-error' }
  | { error: 'validation-error'; message: string };

This achieves the same type safety with less verbosity, as TypeScript will infer undefined fields automatically.

packages/loot-core/src/server/admin/types/handlers.ts (1)

15-17: Consider creating a shared type alias.

Both user-add and user-update share the same return type. Consider extracting it to a type alias:

type UserModificationResult =
  | { error?: string; id?: undefined }
  | { error?: undefined; id: string };

This would improve maintainability and ensure consistency between these related operations.

Also applies to: 21-23

packages/desktop-client/src/components/accounts/Account.tsx (2)

483-487: LGTM! Consider adding a debug log for the null case.

The null check for this.paged is a good defensive programming practice. However, it might be helpful to add a debug log when this.paged is null to help diagnose issues during development.

 if (!this.paged) {
+  console.debug('fetchAllIds: paged query is not initialized');
   return [];
 }

934-937: Consider returning null instead of 0 for better error handling.

While the null check for this.paged is good, returning 0 might mask initialization issues. Consider returning null to make it explicit that the filtered amount couldn't be calculated.

 if (!this.paged) {
-  return 0;
+  return null;
 }

This change would require updating the type annotation and handling the null case in the UI components that use this value.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6573a52 and b4e38d5.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/4147.md is excluded by !**/*.md
📒 Files selected for processing (13)
  • packages/desktop-client/src/components/accounts/Account.tsx (3 hunks)
  • packages/desktop-client/src/components/select/RecurringSchedulePicker.tsx (2 hunks)
  • packages/loot-core/src/client/actions/budgets.ts (1 hunks)
  • packages/loot-core/src/client/data-hooks/transactions.ts (1 hunks)
  • packages/loot-core/src/client/query-helpers.ts (2 hunks)
  • packages/loot-core/src/server/admin/types/handlers.ts (1 hunks)
  • packages/loot-core/src/server/aql/compiler.ts (1 hunks)
  • packages/loot-core/src/server/dashboard/types/handlers.d.ts (1 hunks)
  • packages/loot-core/src/server/rules/types/handlers.ts (1 hunks)
  • packages/loot-core/src/server/schedules/app.ts (1 hunks)
  • packages/loot-core/src/server/schedules/types/handlers.ts (1 hunks)
  • packages/loot-core/src/types/models/simplefin.d.ts (1 hunks)
  • packages/loot-core/src/types/server-handlers.d.ts (6 hunks)
🧰 Additional context used
📓 Learnings (1)
packages/desktop-client/src/components/select/RecurringSchedulePicker.tsx (1)
Learnt from: matt-fidd
PR: actualbudget/actual#4041
File: packages/desktop-client/src/components/select/RecurringSchedulePicker.tsx:518-544
Timestamp: 2024-12-26T01:16:39.339Z
Learning: A <Trans> inside another <Trans> does not necessarily produce two distinct strings. Instead, it merges them into a single translation entry, allowing for object literals to be used within the same translation string.
🔇 Additional comments (17)
packages/loot-core/src/types/models/simplefin.d.ts (1)

5-5: LGTM! Type definitions enhanced with essential properties.

The addition of id to SimpleFinOrganization and balance to SimpleFinAccount improves type completeness and better represents the actual data structure.

Also applies to: 13-13

packages/loot-core/src/server/schedules/types/handlers.ts (1)

18-18: LGTM! Return type enhancement improves type safety.

Changing the return type from Promise<void> to Promise<string> provides better type safety and allows for proper error handling by returning the schedule ID.

packages/loot-core/src/server/admin/types/handlers.ts (1)

9-11: LGTM! Improved error handling for bulk deletion.

The return type now properly handles both partial success and error cases, making it clearer for consumers to handle different scenarios.

packages/loot-core/src/server/rules/types/handlers.ts (1)

48-48: LGTM! Type safety improvements

The changes enhance type safety by replacing unknown return types with specific entity types:

  • rule-get now correctly returns Promise<RuleEntity>
  • rules-run now correctly returns Promise<TransactionEntity>

Also applies to: 50-52

packages/loot-core/src/client/data-hooks/transactions.ts (1)

182-182: LGTM! Added null check for safer access

The addition of the null check t.schedule != null before accessing the schedule property prevents potential runtime errors.

packages/loot-core/src/client/actions/budgets.ts (1)

151-152: Verify type inference from send function

The removal of explicit return types in favor of inference from the send function is cleaner. However, please verify that the inferred types match the expected types in the consuming code.

Run this script to check usage:

Also applies to: 155-156

✅ Verification successful

Type inference from send function verified

The inferred types from send match the server-side implementations:

  • validateBudgetName: Promise<{ valid: boolean; message?: string }>
  • uniqueBudgetName: Promise<string>

All usages in the codebase are consistent with these types.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check how these functions are used to ensure type compatibility

# Find all usages of these functions
echo "Checking validateBudgetName usage:"
rg "validateBudgetName\(" -A 2

echo "Checking uniqueBudgetName usage:"
rg "uniqueBudgetName\(" -A 2

Length of output: 3273

packages/loot-core/src/client/query-helpers.ts (1)

6-6: LGTM! Added type annotation for better type safety

Adding the Query type annotation to the runQuery parameter improves type checking and documentation.

packages/loot-core/src/types/server-handlers.d.ts (5)

53-53: LGTM! Improved type safety for transactions export.

The return type change from Promise<unknown> to Promise<string> provides better type safety by explicitly indicating that the exported query result is a string.


110-110: LGTM! Enhanced type safety for payee rule counts.

The return type change from Promise<unknown> to Promise<Record<string, number>> properly types the mapping between payee IDs and their rule counts.


183-186: LGTM! Added proper error handling types for secret operations.

The return type now includes optional error and reason fields, making error handling more explicit and type-safe.


200-204: LGTM! Improved error handling for SimpleFin accounts.

The return type now properly handles both success and error cases with optional fields for accounts, error code, and reason.


142-142: LGTM! Enhanced type safety for query dependencies.

The return type now explicitly specifies that dependencies is an array of strings, improving type safety.

packages/loot-core/src/server/schedules/app.ts (1)

342-343: LGTM! Added explicit return value for updateSchedule.

The function now properly returns the schedule ID after updating, making it consistent with its Promise return type and allowing callers to track the updated schedule.

packages/desktop-client/src/components/select/RecurringSchedulePicker.tsx (2)

237-241: LGTM! Enhanced type flexibility for SchedulePreview props.

The props type now properly handles both successful cases (string[] for dates) and error cases (string for messages).


376-378: LGTM! Improved state typing for preview dates.

The state type now correctly handles all possible values: string[] for dates, string for error messages, and null for the initial state.

packages/loot-core/src/server/aql/compiler.ts (1)

1008-1010: LGTM! Enhanced type safety with readonly array.

The orderExpressions array is now marked as readonly, preventing accidental modifications and improving type safety.

packages/desktop-client/src/components/accounts/Account.tsx (1)

716-716: LGTM! Robust error handling.

The null check for this.paged complements the existing canCalculateBalance() check, providing comprehensive error handling.

@@ -207,7 +207,7 @@ export class LiveQuery<TResponse = unknown> {
protected fetchData = async (
runQuery: () => Promise<{
data: Data<TResponse>;
dependencies: Set<string>;
dependencies: string[];
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! This is definitely an array of table names

packages/loot-core/src/server/aql/compiler.ts Outdated Show resolved Hide resolved
@jfdoming jfdoming force-pushed the jfdoming/fix-send-types-2 branch from 135bd52 to 5cdbd82 Compare January 18, 2025 03:39
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
packages/desktop-client/src/components/modals/EditUser.tsx (1)

87-93: Consider adding explicit type annotations for better type safety.

While the type narrowing with 'error' in res is good, consider adding explicit type annotations to make the expected response type clear:

-    const res = await send(method, user);
+    type SendResponse = { error: string } | { id?: string };
+    const res: SendResponse = await send(method, user);

This would:

  1. Document the expected response shape
  2. Catch type mismatches at compile time
  3. Make the code more maintainable
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 135bd52 and 5cdbd82.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/4147.md is excluded by !**/*.md
📒 Files selected for processing (15)
  • packages/desktop-client/src/components/accounts/Account.tsx (3 hunks)
  • packages/desktop-client/src/components/modals/EditUser.tsx (1 hunks)
  • packages/desktop-client/src/components/select/RecurringSchedulePicker.tsx (2 hunks)
  • packages/loot-core/src/client/actions/budgets.ts (1 hunks)
  • packages/loot-core/src/client/data-hooks/transactions.ts (1 hunks)
  • packages/loot-core/src/client/query-helpers.ts (2 hunks)
  • packages/loot-core/src/platform/client/fetch/index.d.ts (1 hunks)
  • packages/loot-core/src/server/admin/types/handlers.ts (1 hunks)
  • packages/loot-core/src/server/aql/compiler.ts (2 hunks)
  • packages/loot-core/src/server/dashboard/types/handlers.d.ts (1 hunks)
  • packages/loot-core/src/server/rules/types/handlers.ts (1 hunks)
  • packages/loot-core/src/server/schedules/app.ts (1 hunks)
  • packages/loot-core/src/server/schedules/types/handlers.ts (1 hunks)
  • packages/loot-core/src/types/models/simplefin.d.ts (1 hunks)
  • packages/loot-core/src/types/server-handlers.d.ts (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (11)
  • packages/loot-core/src/client/data-hooks/transactions.ts
  • packages/loot-core/src/types/models/simplefin.d.ts
  • packages/loot-core/src/server/schedules/types/handlers.ts
  • packages/loot-core/src/server/schedules/app.ts
  • packages/desktop-client/src/components/accounts/Account.tsx
  • packages/loot-core/src/server/admin/types/handlers.ts
  • packages/desktop-client/src/components/select/RecurringSchedulePicker.tsx
  • packages/loot-core/src/client/actions/budgets.ts
  • packages/loot-core/src/client/query-helpers.ts
  • packages/loot-core/src/server/dashboard/types/handlers.d.ts
  • packages/loot-core/src/types/server-handlers.d.ts
🧰 Additional context used
🪛 GitHub Check: lint
packages/loot-core/src/server/aql/compiler.ts

[warning] 1-1:
'loot-core/shared/query' import is restricted from being used by a pattern. Please use relative imports in loot-core instead of importing from loot-core/*

🪛 GitHub Actions: Test
packages/loot-core/src/server/aql/compiler.ts

[warning] 1-1: 'loot-core/shared/query' import is restricted from being used by a pattern. Please use relative imports in loot-core instead of importing from loot-core/*

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Visual regression
🔇 Additional comments (4)
packages/loot-core/src/server/rules/types/handlers.ts (2)

48-48: LGTM! Type safety improvement for rule-get.

The change from string to RuleEntity['id'] for the id parameter and the explicit Promise<RuleEntity> return type enhances type safety.


50-52: LGTM! Enhanced type safety for rules-run.

The changes properly type both:

  • Input: Explicit TransactionEntity type for the transaction parameter
  • Output: Clear Promise<TransactionEntity> return type

This eliminates ambiguity and prevents potential type-related errors.

packages/desktop-client/src/components/modals/EditUser.tsx (1)

86-87: LGTM! Improved type safety by removing fallback object.

The removal of the || {} fallback pattern improves type safety by ensuring that send must return a properly typed response.

packages/loot-core/src/server/aql/compiler.ts (1)

1010-1010: LGTM! Type signature improvement.

The updated type signature for customizeQuery is more precise and maintainable. Using QueryState directly instead of a generic type with specific structure improves type safety and readability.

packages/loot-core/src/server/aql/compiler.ts Outdated Show resolved Hide resolved
@jfdoming jfdoming force-pushed the jfdoming/fix-send-types-2 branch from 5cdbd82 to 6b43e75 Compare January 18, 2025 03:49
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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/reports/Overview.tsx (1)

Line range hint 250-290: Improved type safety in error handling.

The change from a simple boolean check to using the in operator is a TypeScript improvement that provides better type narrowing and safer error handling. This ensures that the error property exists on the response object before attempting to access it.

However, consider adding type annotations for the res parameter to make the expected response structure explicit:

-    const res = await send('dashboard-import', { filepath });
+    const res = await send<{ error?: 'json-parse-error' | 'validation-error' | string; message?: string }>('dashboard-import', { filepath });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5cdbd82 and 6b43e75.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/4147.md is excluded by !**/*.md
📒 Files selected for processing (16)
  • packages/desktop-client/src/components/accounts/Account.tsx (3 hunks)
  • packages/desktop-client/src/components/modals/EditUser.tsx (1 hunks)
  • packages/desktop-client/src/components/reports/Overview.tsx (1 hunks)
  • packages/desktop-client/src/components/select/RecurringSchedulePicker.tsx (2 hunks)
  • packages/loot-core/src/client/actions/budgets.ts (1 hunks)
  • packages/loot-core/src/client/actions/prefs.ts (1 hunks)
  • packages/loot-core/src/client/data-hooks/transactions.ts (1 hunks)
  • packages/loot-core/src/client/query-helpers.ts (2 hunks)
  • packages/loot-core/src/platform/client/fetch/index.d.ts (1 hunks)
  • packages/loot-core/src/server/admin/types/handlers.ts (1 hunks)
  • packages/loot-core/src/server/aql/compiler.ts (2 hunks)
  • packages/loot-core/src/server/rules/types/handlers.ts (1 hunks)
  • packages/loot-core/src/server/schedules/app.ts (1 hunks)
  • packages/loot-core/src/server/schedules/types/handlers.ts (2 hunks)
  • packages/loot-core/src/types/models/simplefin.d.ts (1 hunks)
  • packages/loot-core/src/types/server-handlers.d.ts (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (14)
  • packages/loot-core/src/client/data-hooks/transactions.ts
  • packages/loot-core/src/server/schedules/app.ts
  • packages/loot-core/src/types/models/simplefin.d.ts
  • packages/desktop-client/src/components/modals/EditUser.tsx
  • packages/loot-core/src/platform/client/fetch/index.d.ts
  • packages/loot-core/src/client/query-helpers.ts
  • packages/loot-core/src/client/actions/budgets.ts
  • packages/desktop-client/src/components/accounts/Account.tsx
  • packages/loot-core/src/server/rules/types/handlers.ts
  • packages/desktop-client/src/components/select/RecurringSchedulePicker.tsx
  • packages/loot-core/src/server/admin/types/handlers.ts
  • packages/loot-core/src/types/server-handlers.d.ts
  • packages/loot-core/src/server/aql/compiler.ts
  • packages/loot-core/src/server/schedules/types/handlers.ts
🧰 Additional context used
📓 Learnings (1)
packages/loot-core/src/client/actions/prefs.ts (1)
Learnt from: jfdoming
PR: actualbudget/actual#4112
File: packages/loot-core/src/client/actions/prefs.ts:45-47
Timestamp: 2025-01-11T17:39:00.532Z
Learning: The `setI18NextLanguage` function in `packages/desktop-client/src/i18n.ts` has built-in error handling that covers:
1. Special case for English when not available
2. System default language fallback
3. Handling of hyphenated language codes
4. Error logging for unknown locales
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Visual regression
  • GitHub Check: Functional
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
🔇 Additional comments (1)
packages/loot-core/src/client/actions/prefs.ts (1)

46-46: LGTM! The nullish coalescing operator addition improves type safety.

The change to handle undefined language preferences with an empty string fallback aligns well with setI18NextLanguage's built-in error handling, which includes fallback to English and system default language.

@jfdoming jfdoming requested a review from joel-jeremy January 18, 2025 03:56
@@ -41,7 +41,8 @@ export type Unlisten = typeof unlisten;
/** Mock functions */
export function initServer(handlers: {
query: (query: { table: string; selectExpressions: unknown }) => Promise<{
data: unknown;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, what issue was the unknown causing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This particular instance didn't cause any error. The other one in server-handlers.d.ts causes a bunch of errors like Type 'unknown' is not assignable to type 'number' because the result type of a query varies wildly based on the query being run. We could totally have better types here in the future!

Happy to revert the mock if you like, but my thinking is it would be good to keep the mock and implementation types the same

@jfdoming jfdoming requested a review from joel-jeremy January 18, 2025 18:33
Copy link
Contributor

@joel-jeremy joel-jeremy left a comment

Choose a reason for hiding this comment

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

LGTM!

@jfdoming jfdoming merged commit a974715 into actualbudget:master Jan 20, 2025
20 checks passed
@jfdoming jfdoming deleted the jfdoming/fix-send-types-2 branch January 20, 2025 22:09
matt-fidd pushed a commit to matt-fidd/actual that referenced this pull request Jan 21, 2025
* Fix `send` types in a number of places

* Add release notes

* PR feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants