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

[WIP] Migrate Balance.jsx -> Balance.tsx #2329

Closed

Conversation

jfdoming
Copy link
Contributor

@jfdoming jfdoming commented Feb 4, 2024

Relates to #1483

Copy link

netlify bot commented Feb 4, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 953be17
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/65befae2e7d09600080b02f8
😎 Deploy Preview https://deploy-preview-2329.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.

Copy link
Contributor

github-actions bot commented Feb 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
10 4.99 MB → 4.99 MB (+39 B) +0.00%
Changeset
File Δ Size
src/components/accounts/Balance.tsx 🆕 +4.9 kB 0 B → 4.9 kB
src/components/accounts/Balance.jsx 🔥 -4.86 kB (-100%) 4.86 kB → 0 B
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/wide.js 240.49 kB → 240.53 kB (+39 B) +0.02%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/ButtonLink.js 379 B 0%
static/js/BalanceTooltip.js 6.06 kB 0%
static/js/AppliedFilters.js 28.99 kB 0%
static/js/narrow.js 80.18 kB 0%
static/js/ReportRouter.js 1.84 MB 0%
static/js/index.js 2.65 MB 0%

Copy link
Contributor

github-actions bot commented Feb 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.18 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.18 MB 0%

@jfdoming jfdoming force-pushed the jfdoming/balance-typescript branch from 1ff4f76 to c4cc5c9 Compare February 4, 2024 00:29
Copy link
Member

@MatissJanis MatissJanis left a comment

Choose a reason for hiding this comment

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

Overall LGTM. Definitely an improvement over what we have now. Let me know what you think about the comments and if we can do something to improve the situation there.

Comment on lines +10 to +13
export function useSheetValue<T>(
binding: Binding,
onChange?: (result) => void,
): T | null {
Copy link
Member

Choose a reason for hiding this comment

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

❓ question: ‏any way we could make this smarter? For example: I see that binding can have a value. In such case we should be able to extract the type from there. Perhaps we can also extract the type from the binding itself my the name of it?

Basically I'm afraid that manual type definitions here will lead to subtle bugs later.

export function useSelectedItems() {
return useContext(SelectedItems);
export function useSelectedItems<Item>() {
return useContext(SelectedItems) as Set<Item>;
Copy link
Member

Choose a reason for hiding this comment

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

🔨 warning: ‏manual type coercions lead to subtle bugs that are hard to spot.

Could we instead change line 248 to be

const SelectedItems = createContext<Set<string>>(null);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see your point, but I was concerned that the different usages of SelectedItems wouldn't all be strings. I'll double check and fix if they are

Comment on lines +49 to 52
const sheetValue = useSheetValue<string>({
name: rolloverBudget.toBudget,
value: 0,
});
Copy link
Member

Choose a reason for hiding this comment

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

💭 thought: ‏this is what I was afraid of. We manually type this as a string, but the value here is clearly a number.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When sheetValue is used below, it's passed into parseInt, so I assumed it would be a string. Maybe I'm misunderstanding how useSheetValue works?

Copy link
Member

Choose a reason for hiding this comment

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

For now - ignore how sheetValue is used. Focus on the three highlighted lines.

We provide value: 0 in there as the default value. And then we also manually type the return type as string. So which type will be returned? According to the typings: string. But in reality it could as well be number.

Sample: https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABCAzgUwMoAs1qgNQEMAbENAHgBUA+ACgDcSyAuZMAazDgHcwBKVpUQBvAFCIJiAE54QUpI1JpEhFIkoBuUQF9RoiAhRREKHHiJLEAXmTpsuAkwpGpMMAHM6ABj5bRAen9EGDUAA1MHCzJQlUQwEABbACM0KUQ4NMITKFcPAH4gA

Copy link
Contributor

github-actions bot commented Mar 7, 2024

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Mar 7, 2024
@jfdoming
Copy link
Contributor Author

jfdoming commented Mar 7, 2024

Still planning on coming back to address feedback, just been busy with other projects. Will un-stale this PR once.

@github-actions github-actions bot removed the Stale label Mar 8, 2024
@MatissJanis MatissJanis changed the title Migrate Balance.jsx -> Balance.tsx [WIP] Migrate Balance.jsx -> Balance.tsx Mar 9, 2024
@jfdoming
Copy link
Contributor Author

jfdoming commented Apr 1, 2024

Going to close this PR as I've had limited dev time lately and would like to focus on burning down the list of bugs/feature requests for "Splits in Rules"

@jfdoming jfdoming closed this Apr 1, 2024
@jfdoming jfdoming deleted the jfdoming/balance-typescript branch April 1, 2024 06:38
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