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) convert Balance.jsx to .tsx #3874

Closed
Prev Previous commit
Next Next commit
updates DetailedBalanceProps type
  • Loading branch information
cindywu committed Nov 22, 2024
commit 48d632cd056eca3730aa9b5e9374e31616cab183
4 changes: 2 additions & 2 deletions packages/desktop-client/src/components/accounts/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
import { useSheetValue } from '../spreadsheet/useSheetValue';

type DetailedBalanceProps = {
name: any
balance: any
name: string

Check warning on line 23 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `;`
balance: number

Check warning on line 24 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `;`
isExactBalance: boolean

Check warning on line 25 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `;`
}

Check warning on line 26 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `;`

function DetailedBalance({ name, balance, isExactBalance = true }: DetailedBalanceProps) {

Check warning on line 28 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `·name,·balance,·isExactBalance·=·true·` with `⏎··name,⏎··balance,⏎··isExactBalance·=·true,⏎`
const format = useFormat();
return (
<Text
Expand All @@ -48,7 +48,7 @@
);
}

function SelectedBalance({ selectedItems, account }) {

Check failure on line 51 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Binding element 'selectedItems' implicitly has an 'any' type.

Check failure on line 51 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Binding element 'account' implicitly has an 'any' type.
const { t } = useTranslation();

type SelectedBalanceName = `selected-balance-${string}`;
Expand All @@ -66,7 +66,7 @@
const ids = new Set(Array.isArray(rows) ? rows.map(r => r.id) : []);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this always returns an array

Copy link
Author

@cindywu cindywu Nov 23, 2024

Choose a reason for hiding this comment

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

const ids = new Set((rows || []).map(r => r.id));

complains because useSheetValue doesn't always return an array. It can return a number.


const finalIds = [...selectedItems].filter(id => !ids.has(id));
type SelectedBalanceSumName = `selected-balance-${string}-sum`

Check warning on line 69 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `;`
let balance = useSheetValue<'balance', SelectedBalanceName>({
name: (name + '-sum') as SelectedBalanceSumName,
query: q('transactions')
Expand Down Expand Up @@ -96,9 +96,9 @@
}

if (!account || account.id === s._account) {
scheduleBalance += getScheduledAmount(s._amount);

Check failure on line 99 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / typecheck

'scheduleBalance' is possibly 'null'.
} else {
scheduleBalance -= getScheduledAmount(s._amount);

Check failure on line 101 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / typecheck

'scheduleBalance' is possibly 'null'.
}
}
}
Expand All @@ -122,7 +122,7 @@
);
}

function FilteredBalance({ filteredAmount }) {

Check failure on line 125 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Binding element 'filteredAmount' implicitly has an 'any' type.
const { t } = useTranslation();

return (
Expand All @@ -134,16 +134,16 @@
);
}

function MoreBalances({ balanceQuery }) {

Check failure on line 137 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Binding element 'balanceQuery' implicitly has an 'any' type.
const { t } = useTranslation();

type SelectedBalanceClearedName = `balance-query-${string}-cleared`

Check warning on line 140 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `;`
const cleared = useSheetValue<'balance', SelectedBalanceClearedName>({
name: (balanceQuery.name + '-cleared') as SelectedBalanceClearedName,
query: balanceQuery.query.filter({ cleared: true }),
});

type SelectedBalanceUnclearedName = `balance-query-${string}-uncleared`

Check warning on line 146 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `;`
const uncleared = useSheetValue<'balance', SelectedBalanceUnclearedName>({
name: (balanceQuery.name + '-uncleared') as SelectedBalanceUnclearedName,
query: balanceQuery.query.filter({ cleared: false }),
Expand All @@ -151,15 +151,15 @@

return (
<View style={{ flexDirection: 'row' }}>
<DetailedBalance name={t('Cleared total:')} balance={cleared} isExactBalance />

Check warning on line 154 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `·name={t('Cleared·total:')}·balance={cleared}·isExactBalance` with `⏎········name={t('Cleared·total:')}⏎········balance={cleared}⏎········isExactBalance⏎·····`

Check failure on line 154 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Type 'number | null' is not assignable to type 'number'.
<DetailedBalance name={t('Uncleared total:')} balance={uncleared} isExactBalance />

Check warning on line 155 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `·name={t('Uncleared·total:')}·balance={uncleared}·isExactBalance` with `⏎········name={t('Uncleared·total:')}⏎········balance={uncleared}⏎········isExactBalance⏎·····`

Check failure on line 155 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Type 'number | null' is not assignable to type 'number'.
</View>
);
}

export function Balances({
balanceQuery,

Check failure on line 161 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Binding element 'balanceQuery' implicitly has an 'any' type.
showExtraBalances,

Check failure on line 162 in packages/desktop-client/src/components/accounts/Balance.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Binding element 'showExtraBalances' implicitly has an 'any' type.
onToggleExtraBalances,
account,
isFiltered,
Expand Down
Loading