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

♻️ (typescript) migrate parts of ImportTransactionModal to TS #3570

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

MatissJanis
Copy link
Member

No description provided.

@actual-github-bot actual-github-bot bot changed the title ♻️ (typescript) migrate parts of ImportTransactionModal to TS [WIP] ♻️ (typescript) migrate parts of ImportTransactionModal to TS Oct 4, 2024
Copy link
Contributor

coderabbitai bot commented Oct 4, 2024

Walkthrough

This pull request introduces several updates to the type definitions and function signatures of various components within the desktop client application. Key changes include the addition of optional properties for components such as Checkbox, CheckboxOption, and others, enhancing type safety and clarity. A new SelectField component is introduced, replacing the deleted SelectField.jsx. The overall logic of the components remains unchanged, focusing on rendering and interaction while improving type definitions and handling of props. Additionally, several existing components have had their props explicitly typed to ensure better type safety throughout the application.

Possibly related PRs

Suggested labels

::sparkles: Merged

Suggested reviewers

  • joel-jeremy
  • youngcw

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 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

netlify bot commented Oct 4, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 38073f9
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/6706b5284af6070008667b4e
😎 Deploy Preview https://deploy-preview-3570.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.

@MatissJanis MatissJanis changed the title [WIP] ♻️ (typescript) migrate parts of ImportTransactionModal to TS ♻️ (typescript) migrate parts of ImportTransactionModal to TS Oct 4, 2024
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: 4

🧹 Outside diff range and nitpick comments (12)
packages/desktop-client/src/components/modals/ImportTransactionsModal/SubLabel.tsx (1)

10-10: LGTM: Correct TypeScript implementation with a minor suggestion

The function signature has been correctly updated to use the SubLabelProps type, which aligns with the PR objective of migrating to TypeScript.

Consider using object destructuring with the type annotation for improved readability:

export function SubLabel({ title }: { title: string }) {

This approach combines type safety with a concise syntax, potentially eliminating the need for a separate SubLabelProps type for this simple case.

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

8-18: Great job on the TypeScript migration!

The changes successfully migrate the ParsedDate component to TypeScript, improving type safety and maintainability without altering the component's functionality. This aligns well with the PR objective.

As a minor suggestion for further improvement:

Consider adding a more specific type for the date prop instead of using string. For example:

date?: string | null | undefined;

This would more accurately represent the possible values of date as used in the component.

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

Line range hint 1-38: Consider using a more specific type for multiplierAmount

Great job on migrating this component to TypeScript! To further improve type safety, consider using a more specific type for multiplierAmount. If it's always expected to be a numeric string, you could use a union type or a custom type guard to ensure it's a valid number string.

Example:

type NumericString = string & { __numeric: never };

function isNumericString(value: string): value is NumericString {
  return !isNaN(Number(value));
}

type MultiplierOptionProps = {
  // ... other props
  multiplierAmount: NumericString;
  onChangeAmount: (newValue: NumericString) => void;
};

This would require adding a type guard in the onChangeAmount handler, but it would provide stronger guarantees about the multiplierAmount value.

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

Line range hint 1-43: Consider further TypeScript enhancements

Great job on migrating this component to TypeScript! To further leverage TypeScript's capabilities, consider the following suggestions:

  1. Define a type for the style prop of the View component.
  2. Use a more specific type for the id prop of the CheckboxOption component (e.g., 'form_inOut' as a literal type).
  3. Consider using an enum for the inOutMode values if they are used consistently across the application.

These enhancements could provide even more type safety and self-documentation to the code.

packages/desktop-client/src/components/modals/ImportTransactionsModal/SelectField.tsx (2)

6-13: LGTM: Well-defined props type, with a minor suggestion.

The SelectFieldProps type is comprehensive and clearly defines the expected props for the component. However, consider making the firstTransaction type more specific if possible.

Instead of Record<string, unknown>, you could define a more specific type for firstTransaction if the structure is known. For example:

firstTransaction: Record<string, string | number | null>;

This would provide better type safety and make the component's expectations clearer.


15-42: LGTM: Well-implemented component with room for minor improvements.

The SelectField component is well-structured and implements the required functionality effectively. Here are a few suggestions for improvement:

  1. Consider adding a safety check when accessing firstTransaction[option]:
 hasHeaderRow
   ? option
-  : `Column ${parseInt(option) + 1} (${firstTransaction[option]})`,
+  : `Column ${parseInt(option) + 1} (${firstTransaction[option] ?? 'N/A'})`,
  1. For better type safety, you could use a type assertion for the options array:
-      ]}
+      ] as const}

This ensures that TypeScript knows the exact shape of the options array.

  1. Consider memoizing the options array if the component re-renders frequently:
const memoizedOptions = React.useMemo(() => [
  ['choose-field', 'Choose field...'],
  ...options.map(/* ... */),
], [options, hasHeaderRow, firstTransaction]);

Then use memoizedOptions in the Select component.

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

7-14: LGTM: Well-defined prop types with a minor suggestion

The CheckboxOptionProps type is well-defined and covers all necessary props. Using ComponentProps for checked, disabled, and onChange ensures type consistency with the Checkbox component.

Consider making the checked prop required for better type safety:

-  checked?: ComponentProps<typeof Checkbox>['checked'];
+  checked: ComponentProps<typeof Checkbox>['checked'];

This change would ensure that the checked state is always explicitly provided, potentially preventing bugs related to undefined checkbox states.

packages/desktop-client/src/components/modals/ImportTransactionsModal/DateFormatSelect.tsx (2)

13-18: LGTM: Props type definition added correctly.

The DateFormatSelectProps type is well-defined and accurately represents the component's props. It correctly uses the imported types and properly marks parseDateFormat as optional.

Consider using a more specific type for the onChange function parameter:

onChange: (newValue: string | null) => void;

This accounts for the possibility of null being passed when no option is selected in the Select component.


Line range hint 1-53: Overall: Successful TypeScript migration for DateFormatSelect component.

The changes in this file successfully migrate the DateFormatSelect component to TypeScript. The addition of type imports, the new props type definition, and the updated function signature all contribute to improved type safety without altering the component's functionality. This is in line with the PR objective of migrating parts of the ImportTransactionModal to TypeScript.

As you continue migrating other components, consider creating a separate types file (e.g., types.ts) for shared types if they are used across multiple components. This can help maintain consistency and reduce duplication as the migration progresses.

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

67-69: LGTM! Consider using React's CSSProperties type.

The addition of the style property to CheckboxProps is a good improvement, allowing for more flexible styling of the Checkbox component. This change aligns the type definition with the actual usage in the component implementation.

Consider using React's built-in CSSProperties type instead of importing it from a custom style file. This can be done by updating the import statement and type definition as follows:

- import React, { type ReactNode, type ComponentProps } from 'react';
+ import React, { type ReactNode, type ComponentProps, type CSSProperties } from 'react';

- import { type CSSProperties, theme } from '../style';
+ import { theme } from '../style';

This change would make the code more standardized and reduce dependencies on custom type definitions.

packages/desktop-client/src/components/modals/ImportTransactionsModal/FieldMappings.tsx (2)

11-18: LGTM: Well-defined FieldMappingsProps type

The FieldMappingsProps type is well-structured and includes all necessary properties. The optional mappings property aligns well with the default value provided in the component.

Consider adding JSDoc comments to describe the purpose of each prop, especially for boolean flags like splitMode, inOutMode, and hasHeaderRow. This would enhance code documentation and improve maintainability.

Example:

type FieldMappingsProps = {
  /** Array of transactions to be imported */
  transactions: ImportTransaction[];
  /** Mapping of CSV fields to transaction properties */
  mappings?: FieldMapping;
  /** Callback function when a mapping is changed */
  onChange: (field: keyof FieldMapping, newValue: string) => void;
  /** Flag to indicate if the transaction should be split */
  splitMode: boolean;
  /** Flag to indicate if inflow/outflow mode is active */
  inOutMode: boolean;
  /** Flag to indicate if the CSV file has a header row */
  hasHeaderRow: boolean;
};

20-36: LGTM: Improved function signature with TypeScript and default values

The updated FieldMappings function signature is well-structured. The use of destructuring with default values for the mappings prop is a good practice, ensuring all necessary fields are initialized.

Consider using the Required<T> utility type for the default mappings object to ensure type safety. This will make it clear that all properties of FieldMapping are present in the default value:

mappings: Required<FieldMapping> = {
  date: null,
  amount: null,
  payee: null,
  notes: null,
  inOut: null,
  category: null,
  outflow: null,
  inflow: null,
},

This change would provide an additional layer of type checking and make the code more robust against future changes to the FieldMapping type.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a28fb93 and 7bb8c17.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/3570.md is excluded by !**/*.md
📒 Files selected for processing (13)
  • packages/desktop-client/src/components/forms.tsx (1 hunks)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/CheckboxOption.tsx (2 hunks)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/DateFormatSelect.tsx (1 hunks)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/FieldMappings.tsx (1 hunks)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/InOutOption.tsx (1 hunks)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/MultiplierOption.tsx (1 hunks)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/ParsedDate.tsx (1 hunks)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/SelectField.jsx (0 hunks)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/SelectField.tsx (1 hunks)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/SubLabel.tsx (1 hunks)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/Transaction.tsx (5 hunks)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.test.ts (2 hunks)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.ts (6 hunks)
💤 Files with no reviewable changes (1)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/SelectField.jsx
🔇 Additional comments (30)
packages/desktop-client/src/components/modals/ImportTransactionsModal/SubLabel.tsx (2)

6-8: LGTM: Well-defined prop type

The SubLabelProps type is correctly defined and follows TypeScript best practices. It accurately represents the component's prop structure.


6-10: Summary: Successful TypeScript migration

The changes successfully migrate the SubLabel component to TypeScript without altering its functionality. This improves type safety and code maintainability, aligning well with the PR objectives.

Key points:

  1. A new SubLabelProps type is introduced.
  2. The function signature is updated to use TypeScript.
  3. The component's logic remains unchanged.

These modifications enhance the codebase's overall quality and consistency.

packages/desktop-client/src/components/modals/ImportTransactionsModal/ParsedDate.tsx (2)

8-12: LGTM! Well-defined type for component props.

The ParsedDateProps type is well-structured and enhances type safety for the component. Good job on using Parameters<typeof parseDate>[1] to ensure type consistency with the parseDate function. The optional properties are correctly marked, aligning with their usage in the component.


14-18: LGTM! Function signature updated correctly.

The ParsedDate function signature has been properly updated to use the new ParsedDateProps type. This change enhances type safety and improves code readability while maintaining consistency with the implementation.

packages/desktop-client/src/components/modals/ImportTransactionsModal/MultiplierOption.tsx (2)

8-13: LGTM: Well-defined prop types

The MultiplierOptionProps type is well-defined and uses appropriate types for each prop. Good job on using ComponentProps to derive the onToggle type from the CheckboxOption component, ensuring type consistency.


14-20: LGTM: Improved type safety with explicit prop typing

The MultiplierOption component now uses explicit prop typing with MultiplierOptionProps. This change enhances type safety and code readability without altering the component's functionality.

packages/desktop-client/src/components/modals/ImportTransactionsModal/InOutOption.tsx (2)

8-14: LGTM: Well-defined TypeScript interface for component props

The InOutOptionProps type is well-structured and provides clear type definitions for all the props used by the InOutOption component. This addition enhances code readability and type safety.


15-22: LGTM: Proper implementation of TypeScript typing

The function signature has been correctly updated to use the newly defined InOutOptionProps type. This change enhances type safety and maintains consistency with the new type definition.

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

1-4: LGTM: Imports are appropriate and well-structured.

The imports are correctly defined and follow a clear project structure. The use of relative paths for internal imports is a good practice.

packages/desktop-client/src/components/modals/ImportTransactionsModal/CheckboxOption.tsx (4)

1-3: LGTM: Appropriate TypeScript imports added

The new imports (ComponentProps, ReactNode, and CSSProperties) are correctly added and necessary for the TypeScript migration. They provide proper typing for the component's props and styles.


23-23: LGTM: Proper TypeScript function signature

The function signature has been correctly updated to use the CheckboxOptionProps type. This change enhances type safety and aligns with TypeScript best practices for React components.


45-45: LGTM: Improved style handling for disabled state

The change from null to undefined for the color property when the checkbox is disabled is an improvement. It's more idiomatic in TypeScript/JavaScript and likely provides better consistency with the theme system.

To ensure this change doesn't unexpectedly affect the styling, please verify the appearance of disabled checkboxes in various states and themes.


Line range hint 1-52: Summary: Successful TypeScript migration with minor suggestions

The migration of the CheckboxOption component to TypeScript has been implemented successfully. The changes improve type safety, enhance code clarity, and align with TypeScript best practices. A few minor suggestions have been made to further improve the component:

  1. Consider making the checked prop required for better type safety.
  2. Verify the appearance of disabled checkboxes with the new style handling.

Overall, these changes will contribute to better maintainability and reliability of the codebase.

packages/desktop-client/src/components/modals/ImportTransactionsModal/DateFormatSelect.tsx (2)

7-11: LGTM: New type imports added correctly.

The addition of ImportTransaction and FieldMapping type imports from './utils' is consistent with the PR objective of migrating to TypeScript. These imports are correctly placed and follow the existing import structure.


20-25: LGTM: Function signature updated correctly.

The DateFormatSelect function signature has been properly updated to use the new DateFormatSelectProps type. This change enhances type safety and clarity of the component's interface, which is in line with the PR objective of migrating to TypeScript.

packages/desktop-client/src/components/modals/ImportTransactionsModal/FieldMappings.tsx (2)

9-9: LGTM: Clean type imports

The addition of explicit type imports from the utils file is a good practice in TypeScript. It improves code readability and type safety.


Line range hint 1-153: Great job on the TypeScript migration!

The changes successfully migrate the FieldMappings component to TypeScript without altering its functionality. This migration enhances type safety, improves code readability, and aligns well with the PR objectives.

Key improvements:

  1. Addition of the FieldMappingsProps type for better prop typing.
  2. Updated function signature with proper TypeScript annotations.
  3. Use of imported types from the utils file.

These changes contribute to a more robust and maintainable codebase. Great work on keeping the functional aspects unchanged while improving the type safety!

packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.test.ts (4)

3-4: LGTM: Arrow function conversion for describe blocks

The conversion of traditional function expressions to arrow functions in the describe blocks enhances consistency in the test structure and aligns with modern JavaScript practices.


5-8: Excellent: Improved type safety for invalidInputs array

The addition of explicit type definitions for the invalidInputs array using TypeScript's Parameters utility type is a great improvement. This change:

  1. Enhances type safety by ensuring that the test inputs align with the expected parameters of the parseDate function.
  2. Makes the code more self-documenting and easier to maintain.
  3. Leverages TypeScript's advanced type inference capabilities.

Great job on improving the code quality and type safety!


43-46: Excellent: Enhanced type safety for validInputs array

The addition of explicit type definitions for the validInputs array using TypeScript's Parameters and ReturnType utility types is a significant improvement. This change:

  1. Enhances type safety by ensuring that both the test inputs and expected outputs align with the parseDate function signature.
  2. Makes the code more self-documenting and easier to maintain.
  3. Leverages TypeScript's advanced type inference capabilities.
  4. Uses the ReturnType utility type to ensure that the expected output type matches the actual return type of parseDate, adding an extra layer of type checking.

Excellent work on improving the code quality, type safety, and maintainability of the test suite!


Line range hint 1-180: Overall: Excellent TypeScript migration for ImportTransactionsModal tests

The changes made to this file consistently improve type safety and code quality, aligning perfectly with the PR objective of migrating parts of ImportTransactionModal to TypeScript. The use of arrow functions and TypeScript's utility types enhances the maintainability and robustness of the test suite.

Great job on this migration! The changes are well-thought-out and contribute to a more type-safe and easier-to-maintain codebase.

packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.ts (1)

13-13: Good use of as const to maintain literal types of dateFormats

The addition of as const ensures that the dateFormats array retains its literal types, enhancing type safety when using these values elsewhere in the code.

packages/desktop-client/src/components/modals/ImportTransactionsModal/Transaction.tsx (8)

1-1: Good use of TypeScript type imports

Importing type ComponentProps and useMemo from 'react' improves type safety and code clarity.


4-4: Correctly importing CategoryEntity type

The import of type CategoryEntity from 'loot-core/types/models' ensures accurate type annotations for category-related data.


15-22: Comprehensive imports from './utils'

Importing both functions and types (applyFieldMappings, formatDate, parseAmountFields, FieldMapping, ImportTransaction) from './utils' enhances modularity and reuse.


23-37: Defining TransactionProps enhances type safety

Creating the TransactionProps type provides clear expectations for the component's props, improving maintainability and reducing potential bugs.


53-53: Annotating Transaction component with TransactionProps

Using TransactionProps in the component signature aligns with TypeScript best practices and ensures consistent prop usage.


63-90: Optimizing calculations with useMemo

Employing useMemo for computing amount, outflow, and inflow boosts performance by avoiding unnecessary recalculations when dependencies haven't changed.


251-255: Proper handling of transaction.inOut in title attribute

The conditional logic correctly avoids setting the title when transaction.inOut is undefined, preventing potential UI issues related to displaying undefined values.


33-33: Verify the type of multiplierAmount

multiplierAmount is typed as a string, but verify that parseAmountFields expects a string for this parameter. If it requires a numeric value, consider parsing the string to a number before passing it.

Run the following script to confirm the expected type:

@MatissJanis MatissJanis changed the title ♻️ (typescript) migrate parts of ImportTransactionModal to TS [WIP] ♻️ (typescript) migrate parts of ImportTransactionModal to TS Oct 4, 2024
Copy link
Contributor

github-actions bot commented Oct 4, 2024

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
9 5.32 MB → 5.32 MB (-42 B) -0.00%
Changeset
File Δ Size
src/components/modals/ImportTransactionsModal/Transaction.tsx 🆕 +8.19 kB 0 B → 8.19 kB
src/components/modals/ImportTransactionsModal/FieldMappings.tsx 🆕 +5.89 kB 0 B → 5.89 kB
src/components/modals/ImportTransactionsModal/utils.ts 🆕 +4.11 kB 0 B → 4.11 kB
src/components/modals/ImportTransactionsModal/ParsedDate.tsx 🆕 +806 B 0 B → 806 B
src/components/modals/ImportTransactionsModal/DateFormatSelect.tsx 🆕 +784 B 0 B → 784 B
src/components/modals/ImportTransactionsModal/MultiplierOption.tsx 🆕 +737 B 0 B → 737 B
src/components/modals/ImportTransactionsModal/InOutOption.tsx 🆕 +734 B 0 B → 734 B
src/components/modals/ImportTransactionsModal/CheckboxOption.tsx 🆕 +667 B 0 B → 667 B
src/components/modals/ImportTransactionsModal/SelectField.tsx 🆕 +476 B 0 B → 476 B
src/components/modals/ImportTransactionsModal/SubLabel.tsx 🆕 +204 B 0 B → 204 B
src/components/modals/ImportTransactionsModal/Transaction.jsx 🔥 -7.94 kB (-100%) 7.94 kB → 0 B
src/components/modals/ImportTransactionsModal/FieldMappings.jsx 🔥 -5.79 kB (-100%) 5.79 kB → 0 B
src/components/modals/ImportTransactionsModal/utils.js 🔥 -4.51 kB (-100%) 4.51 kB → 0 B
src/components/modals/ImportTransactionsModal/ParsedDate.jsx 🔥 -806 B (-100%) 806 B → 0 B
src/components/modals/ImportTransactionsModal/DateFormatSelect.jsx 🔥 -784 B (-100%) 784 B → 0 B
src/components/modals/ImportTransactionsModal/MultiplierOption.jsx 🔥 -737 B (-100%) 737 B → 0 B
src/components/modals/ImportTransactionsModal/InOutOption.jsx 🔥 -734 B (-100%) 734 B → 0 B
src/components/modals/ImportTransactionsModal/CheckboxOption.jsx 🔥 -665 B (-100%) 665 B → 0 B
src/components/modals/ImportTransactionsModal/SelectField.jsx 🔥 -476 B (-100%) 476 B → 0 B
src/components/modals/ImportTransactionsModal/SubLabel.jsx 🔥 -204 B (-100%) 204 B → 0 B
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

Asset File Size % Changed
static/js/index.js 3.34 MB → 3.34 MB (-42 B) -0.00%

Unchanged

Asset File Size % Changed
static/js/resize-observer.js 18.37 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/usePreviewTransactions.js 1.64 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/AppliedFilters.js 20.96 kB 0%
static/js/narrow.js 82.55 kB 0%
static/js/wide.js 224.88 kB 0%
static/js/ReportRouter.js 1.51 MB 0%

Copy link
Contributor

github-actions bot commented Oct 4, 2024

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.26 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.js 1.26 MB 0%

@MatissJanis MatissJanis changed the title [WIP] ♻️ (typescript) migrate parts of ImportTransactionModal to TS ♻️ (typescript) migrate parts of ImportTransactionModal to TS Oct 5, 2024
@MikesGlitch MikesGlitch self-assigned this Oct 7, 2024
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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7bb8c17 and 38073f9.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/3603.md is excluded by !**/*.md
📒 Files selected for processing (2)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/FieldMappings.tsx (1 hunks)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.ts (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/FieldMappings.tsx
🧰 Additional context used
📓 Learnings (2)
📓 Common learnings
Learnt from: MatissJanis
PR: actualbudget/actual#3570
File: packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.ts:120-130
Timestamp: 2024-10-05T10:59:08.817Z
Learning: Avoid overcomplicating the `ImportTransaction` type; prefer to keep it simple.
Learnt from: MatissJanis
PR: actualbudget/actual#3570
File: packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.ts:120-130
Timestamp: 2024-10-08T15:46:15.739Z
Learning: Avoid overcomplicating the `ImportTransaction` type; prefer to keep it simple.
packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.ts (4)
Learnt from: MatissJanis
PR: actualbudget/actual#3570
File: packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.ts:120-130
Timestamp: 2024-10-08T15:46:15.739Z
Learning: Avoid overcomplicating the `ImportTransaction` type; prefer to keep it simple.
Learnt from: MatissJanis
PR: actualbudget/actual#3570
File: packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.ts:120-130
Timestamp: 2024-10-05T10:59:08.817Z
Learning: Avoid overcomplicating the `ImportTransaction` type; prefer to keep it simple.
Learnt from: MatissJanis
PR: actualbudget/actual#3570
File: packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.ts:16-24
Timestamp: 2024-10-08T15:46:15.739Z
Learning: In `packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.ts`, the `parseDate` function's `str` parameter should maintain its current type `string | number | null | Array<unknown> | object`, as narrowing it to `string | null` is not suitable.
Learnt from: MatissJanis
PR: actualbudget/actual#3570
File: packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.ts:16-24
Timestamp: 2024-10-05T10:58:55.009Z
Learning: In `packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.ts`, the `parseDate` function's `str` parameter should maintain its current type `string | number | null | Array<unknown> | object`, as narrowing it to `string | null` is not suitable.
🔇 Additional comments (3)
packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.ts (3)

13-14: Using as const on dateFormats ensures literal types

Adding as const to dateFormats ensures that each format and label is treated as a literal type. This enhances type safety by preventing modifications to the array elements and improves type inference elsewhere in the code.


15-24: Enhanced type annotations in parseDate function improve clarity

The explicit type annotations for the parseDate function's parameters enhance code clarity and type safety. Specifying the exact string literals for the order parameter ensures that only valid date formats are used.


181-187: Appropriate use of Partial<ImportTransaction> in parseAmountFields

Using Partial<ImportTransaction> for the trans parameter in parseAmountFields allows the function to handle incomplete transaction data gracefully, enhancing flexibility and robustness.

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