Skip to content

Commit

Permalink
explicitly type anys
Browse files Browse the repository at this point in the history
  • Loading branch information
cindywu committed Nov 22, 2024
1 parent 8229290 commit b26d36c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
39 changes: 27 additions & 12 deletions packages/desktop-client/src/components/accounts/Balance.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react';
import React, { useRef, type ComponentProps } from 'react';
import { useTranslation } from 'react-i18next';

import { useHover } from 'usehooks-ts';
Expand All @@ -7,6 +7,7 @@ import { isPreviewId } from 'loot-core/shared/transactions';
import { useCachedSchedules } from 'loot-core/src/client/data-hooks/schedules';
import { q } from 'loot-core/src/shared/query';
import { getScheduledAmount } from 'loot-core/src/shared/schedules';
import { type AccountEntity } from 'loot-core/types/models';

import { useSelectedItems } from '../../hooks/useSelected';
import { SvgArrowButtonRight1 } from '../../icons/v2';
Expand All @@ -16,9 +17,12 @@ import { Text } from '../common/Text';
import { View } from '../common/View';
import { PrivacyFilter } from '../PrivacyFilter';
import { CellValue, CellValueText } from '../spreadsheet/CellValue';
import { type SheetFields, type SheetNames } from '../spreadsheet/index';
import { useFormat } from '../spreadsheet/useFormat';
import { useSheetValue } from '../spreadsheet/useSheetValue';

import { type ReconcilingMessage } from './Reconcile';

type DetailedBalanceProps = {
name: string;
balance: number | null;
Expand Down Expand Up @@ -56,8 +60,8 @@ function SelectedBalance({
selectedItems,
account,
}: {
selectedItems: any;
account: any;
selectedItems: Set<string>;
account: AccountEntity;
}) {
const { t } = useTranslation();

Expand Down Expand Up @@ -132,7 +136,7 @@ function SelectedBalance({
);
}

function FilteredBalance({ filteredAmount }: { filteredAmount: any }) {
function FilteredBalance({ filteredAmount }: { filteredAmount: number }) {
const { t } = useTranslation();

return (
Expand All @@ -144,7 +148,11 @@ function FilteredBalance({ filteredAmount }: { filteredAmount: any }) {
);
}

function MoreBalances({ balanceQuery }: { balanceQuery: any }) {
function MoreBalances({
balanceQuery,
}: {
balanceQuery: ComponentProps<typeof ReconcilingMessage>['balanceQuery'];
}) {
const { t } = useTranslation();

type SelectedBalanceClearedName = `balance-query-${string}-cleared`;
Expand Down Expand Up @@ -176,12 +184,12 @@ function MoreBalances({ balanceQuery }: { balanceQuery: any }) {
}

type BalancesProps = {
balanceQuery: any;
showExtraBalances: any;
onToggleExtraBalances: any;
account: any;
isFiltered: any;
filteredAmount: any;
balanceQuery: ComponentProps<typeof ReconcilingMessage>['balanceQuery'];
showExtraBalances: boolean;
onToggleExtraBalances: () => void;
account: AccountEntity;
isFiltered: boolean;
filteredAmount: number;
};

export function Balances({
Expand Down Expand Up @@ -215,7 +223,14 @@ export function Balances({
paddingBottom: 1,
}}
>
<CellValue binding={{ ...balanceQuery, value: 0 }} type="financial">
<CellValue
binding={{
name: balanceQuery.name as SheetFields<SheetNames>,
query: balanceQuery.query,
value: 0,
}}
type="financial"
>
{props => (
<CellValueText
{...props}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export type Spreadsheets = {
'uncategorized-balance': number;

// Balance fields
[key: `balance-query-${string}`]: number;
[key: `balance-query-${string}-cleared`]: number;
[key: `balance-query-${string}-uncleared`]: number;
[key: `selected-balance-${string}`]: number;
Expand Down

0 comments on commit b26d36c

Please sign in to comment.