Skip to content

Commit

Permalink
shared type, shhh eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd committed Jan 2, 2025
1 parent 30bf0c6 commit 519926b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
7 changes: 5 additions & 2 deletions packages/desktop-client/src/components/LoggedInUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useLocation } from 'react-router-dom';
import { closeBudget, getUserData, signOut } from 'loot-core/client/actions';
import { type State } from 'loot-core/src/client/state-types';
import { type RemoteFile, type SyncedLocalFile } from 'loot-core/types/file';
import { type TransObjectLiteral } from 'loot-core/types/util';

import { useAuth } from '../auth/AuthProvider';
import { Permissions } from '../auth/types';
Expand Down Expand Up @@ -208,7 +209,9 @@ export function LoggedInUser({
(
<Trans>
logged in as:{' '}
<span>{{ userName: userData?.displayName } as any}</span>
<span>
{{ userName: userData?.displayName } as TransObjectLiteral}
</span>
</Trans>
)
</small>
Expand All @@ -224,7 +227,7 @@ export function LoggedInUser({
logged in as:{' '}
<span>
<PrivacyFilter>
{{ userName: userData?.displayName } as any}
{{ userName: userData?.displayName } as TransObjectLiteral}
</PrivacyFilter>
</span>
</Trans>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from 'loot-core/client/actions';
import { integerToCurrency } from 'loot-core/src/shared/util';
import { type AccountEntity } from 'loot-core/src/types/models';
import { type TransObjectLiteral } from 'loot-core/types/util';

import { useAccounts } from '../../hooks/useAccounts';
import { useCategories } from '../../hooks/useCategories';
Expand Down Expand Up @@ -121,7 +122,10 @@ export function CloseAccountModal({
<Paragraph>
<Trans>
Are you sure you want to close{' '}
<strong>{{ accountName: account.name } as any}</strong>?{' '}
<strong>
{{ accountName: account.name } as TransObjectLiteral}
</strong>
?{' '}
</Trans>
{canDelete ? (
<span>
Expand Down Expand Up @@ -151,7 +155,11 @@ export function CloseAccountModal({
<Trans>
This account has a balance of{' '}
<strong>
{{ balance: integerToCurrency(balance) } as any}
{
{
balance: integerToCurrency(balance),
} as TransObjectLiteral
}
</strong>
. To close this account, select a different account to
transfer this balance to:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { Trans } from 'react-i18next';

import { type TransObjectLiteral } from 'loot-core/types/util';

import { theme } from '../../style/theme';
import { Button } from '../common/Button2';
import { Stack } from '../common/Stack';
Expand All @@ -25,7 +27,7 @@ export function SaveReportDelete({
<Text style={{ color: theme.errorText, marginBottom: 5 }}>
Are you sure you want to delete report:{' '}
</Text>
<View>{{ name } as any}</View>
<View>{{ name } as TransObjectLiteral}</View>
</Trans>
</View>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import { sendCatch } from 'loot-core/src/platform/client/fetch';
import * as monthUtils from 'loot-core/src/shared/months';
import { getRecurringDescription } from 'loot-core/src/shared/schedules';
import { type RecurConfig, type RecurPattern } from 'loot-core/types/models';
import { type WithRequired } from 'loot-core/types/util';
import {
type TransObjectLiteral,
type WithRequired,
} from 'loot-core/types/util';

import { useDateFormat } from '../../hooks/useDateFormat';
import { SvgAdd, SvgSubtract } from '../../icons/v0';
Expand Down Expand Up @@ -540,7 +543,7 @@ function RecurringScheduleTooltip({
style={{ userSelect: 'none', marginLeft: 5 }}
>
{' '}
{{ beforeOrAfter: '' } as any} weekend
{{ beforeOrAfter: '' } as TransObjectLiteral} weekend
</label>
</Trans>
</View>
Expand Down
5 changes: 5 additions & 0 deletions packages/loot-core/src/types/util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ export type EverythingButIdOptional<T> = { id: T['id'] } & Partial<
>;

export type WithRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;

// Allows use of object literals inside child elements of `Trans` tags
// see https://github.com/i18next/react-i18next/issues/1483
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type TransObjectLiteral = any;

0 comments on commit 519926b

Please sign in to comment.