diff --git a/packages/desktop-client/src/components/FatalError.tsx b/packages/desktop-client/src/components/FatalError.tsx index ebed6c72ee6946cefa8090d41fe621ec0abddb31..9b96ba0fe5c2e54167531c8fa4c41334ed4f897c 100644 --- a/packages/desktop-client/src/components/FatalError.tsx +++ b/packages/desktop-client/src/components/FatalError.tsx @@ -166,7 +166,9 @@ export function FatalError({ buttonText, error }: FatalErrorProps) { > {showSimpleRender ? <RenderSimple error={error} /> : <RenderUIError />} <Paragraph> - <Button onClick={() => window.Actual.relaunch()}>{buttonText}</Button> + <Button onClick={() => window.Actual?.relaunch()}> + {buttonText} + </Button> </Paragraph> <Paragraph isLast={true} style={{ fontSize: 11 }}> <LinkButton onClick={() => setShowError(true)}>Show Error</LinkButton> diff --git a/packages/desktop-client/src/components/GlobalKeys.ts b/packages/desktop-client/src/components/GlobalKeys.ts index 1109e4250cb9df4f28078bf002fd16211edf19c7..a6e785347f2bbfbebd5670cdf4bc2f650dae6e63 100644 --- a/packages/desktop-client/src/components/GlobalKeys.ts +++ b/packages/desktop-client/src/components/GlobalKeys.ts @@ -1,4 +1,3 @@ -// @ts-strict-ignore import { useEffect } from 'react'; import * as Platform from 'loot-core/src/client/platform'; @@ -8,7 +7,7 @@ import { useNavigate } from '../hooks/useNavigate'; export function GlobalKeys() { const navigate = useNavigate(); useEffect(() => { - const handleKeys = e => { + const handleKeys = (e: KeyboardEvent) => { if (Platform.isBrowser) { return; } diff --git a/packages/desktop-client/src/components/accounts/Account.jsx b/packages/desktop-client/src/components/accounts/Account.jsx index 48f30a99a4490c7de247f868a0f8dcacc8830a4b..18a560f997984e3fa66a4e815938556cba700697 100644 --- a/packages/desktop-client/src/components/accounts/Account.jsx +++ b/packages/desktop-client/src/components/accounts/Account.jsx @@ -470,7 +470,7 @@ class AccountInternal extends PureComponent { const categories = await this.props.getCategories(); if (account) { - const res = await window.Actual.openFileDialog({ + const res = await window.Actual?.openFileDialog({ filters: [ { name: 'Financial Files', @@ -502,7 +502,7 @@ class AccountInternal extends PureComponent { accountName && accountName.replace(/[()]/g, '').replace(/\s+/g, '-'); const filename = `${normalizedName || 'transactions'}.csv`; - window.Actual.saveFile( + window.Actual?.saveFile( exportedTransactions, filename, 'Export Transactions', diff --git a/packages/desktop-client/src/components/manager/ImportActual.tsx b/packages/desktop-client/src/components/manager/ImportActual.tsx index 665c4ea8ff34825bcce844e1e953da5753ccaa7b..a6863deb536004b22d9a41cb717accb6fb0b4d43 100644 --- a/packages/desktop-client/src/components/manager/ImportActual.tsx +++ b/packages/desktop-client/src/components/manager/ImportActual.tsx @@ -38,7 +38,7 @@ export function ImportActual({ modalProps }: ImportProps) { const [importing, setImporting] = useState(false); async function onImport() { - const res = await window.Actual.openFileDialog({ + const res = await window.Actual?.openFileDialog({ properties: ['openFile'], filters: [{ name: 'actual', extensions: ['zip', 'blob'] }], }); diff --git a/packages/desktop-client/src/components/manager/ImportYNAB4.tsx b/packages/desktop-client/src/components/manager/ImportYNAB4.tsx index f95de762c22483837d47394b89b96ea6e3d59e00..338a5dd5e27aad16682f04be40ec54ed25d81a30 100644 --- a/packages/desktop-client/src/components/manager/ImportYNAB4.tsx +++ b/packages/desktop-client/src/components/manager/ImportYNAB4.tsx @@ -30,7 +30,7 @@ export function ImportYNAB4({ modalProps }: ImportProps) { const [importing, setImporting] = useState(false); async function onImport() { - const res = await window.Actual.openFileDialog({ + const res = await window.Actual?.openFileDialog({ properties: ['openFile'], filters: [{ name: 'ynab', extensions: ['zip'] }], }); diff --git a/packages/desktop-client/src/components/manager/ImportYNAB5.tsx b/packages/desktop-client/src/components/manager/ImportYNAB5.tsx index 0e0a2be5cb30f334317022a3d62001c4d7cba6f6..0a775c1fb2fc0c3c0930e4019e31da157ce07944 100644 --- a/packages/desktop-client/src/components/manager/ImportYNAB5.tsx +++ b/packages/desktop-client/src/components/manager/ImportYNAB5.tsx @@ -33,7 +33,7 @@ export function ImportYNAB5({ modalProps }: ImportProps) { const [importing, setImporting] = useState(false); async function onImport() { - const res = await window.Actual.openFileDialog({ + const res = await window.Actual?.openFileDialog({ properties: ['openFile'], filters: [{ name: 'ynab', extensions: ['json'] }], }); diff --git a/packages/desktop-client/src/components/manager/ManagementApp.jsx b/packages/desktop-client/src/components/manager/ManagementApp.jsx index 1bc3f407eff4426938021b841aac6b881b2ae117..c5200986f3af44282d47909c01b904607a43d4e8 100644 --- a/packages/desktop-client/src/components/manager/ManagementApp.jsx +++ b/packages/desktop-client/src/components/manager/ManagementApp.jsx @@ -42,7 +42,7 @@ function Version() { }, }} > - {`App: v${window.Actual.ACTUAL_VERSION} | Server: ${version}`} + {`App: v${window.Actual?.ACTUAL_VERSION} | Server: ${version}`} </Text> ); } diff --git a/packages/desktop-client/src/components/modals/ImportTransactions.jsx b/packages/desktop-client/src/components/modals/ImportTransactions.jsx index 3bd05e3008cfe13e24474c3b4ced92c957d3bcd1..10e79776dd386a6eddc17cd7fd86623c99dc40ec 100644 --- a/packages/desktop-client/src/components/modals/ImportTransactions.jsx +++ b/packages/desktop-client/src/components/modals/ImportTransactions.jsx @@ -849,7 +849,7 @@ export function ImportTransactions({ modalProps, options }) { } async function onNewFile() { - const res = await window.Actual.openFileDialog({ + const res = await window.Actual?.openFileDialog({ filters: [ { name: 'Financial Files', diff --git a/packages/desktop-client/src/components/settings/Export.tsx b/packages/desktop-client/src/components/settings/Export.tsx index 824c0f4fa41b7f96f6d7284f05a435b9d9b8afb3..790db44dfd784f8a01378cac82a0df0404394321 100644 --- a/packages/desktop-client/src/components/settings/Export.tsx +++ b/packages/desktop-client/src/components/settings/Export.tsx @@ -1,4 +1,3 @@ -// @ts-strict-ignore import React, { useState } from 'react'; import { format } from 'date-fns'; @@ -32,7 +31,7 @@ export function ExportBudget() { return; } - window.Actual.saveFile( + window.Actual?.saveFile( response.data, `${format(new Date(), 'yyyy-MM-dd')}-${budgetId}.zip`, 'Export budget', diff --git a/packages/desktop-client/src/components/settings/FixSplits.tsx b/packages/desktop-client/src/components/settings/FixSplits.tsx index dab88d8b8b1e108b14bd8432d5b9801f5dcfab77..8a8be2a7feb7f10c433ffe65e031ee2373badf00 100644 --- a/packages/desktop-client/src/components/settings/FixSplits.tsx +++ b/packages/desktop-client/src/components/settings/FixSplits.tsx @@ -1,4 +1,3 @@ -// @ts-strict-ignore import React, { useState } from 'react'; import { send } from 'loot-core/src/platform/client/fetch'; @@ -54,7 +53,7 @@ function renderResults(results: Results) { export function FixSplits() { const [loading, setLoading] = useState(false); - const [results, setResults] = useState<Results>(null); + const [results, setResults] = useState<Results | null>(null); async function onFix() { setLoading(true); diff --git a/packages/desktop-client/src/components/settings/Global.tsx b/packages/desktop-client/src/components/settings/Global.tsx index 92e4ba843a871fbf15cad60f2940fbfea4ddeb4c..da9fa01d744069d19a11695345fa26ab4bf17f35 100644 --- a/packages/desktop-client/src/components/settings/Global.tsx +++ b/packages/desktop-client/src/components/settings/Global.tsx @@ -1,4 +1,3 @@ -// @ts-strict-ignore import React, { useState, useEffect, useRef } from 'react'; import { useGlobalPref } from '../../hooks/useGlobalPref'; @@ -23,7 +22,7 @@ export function GlobalSettings() { }, []); async function onChooseDocumentDir() { - const res = await window.Actual.openFileDialog({ + const res = await window.Actual?.openFileDialog({ properties: ['openDirectory'], }); if (res) { diff --git a/packages/desktop-client/src/components/settings/Reset.tsx b/packages/desktop-client/src/components/settings/Reset.tsx index 0e8ea3cea5a2fd1cf97441fd8dd25b2fb051af0f..78d7f88a9dcf1ccfc2b4babea8c44464b2ea668f 100644 --- a/packages/desktop-client/src/components/settings/Reset.tsx +++ b/packages/desktop-client/src/components/settings/Reset.tsx @@ -1,4 +1,3 @@ -// @ts-strict-ignore import React, { useState } from 'react'; import { send } from 'loot-core/src/platform/client/fetch'; diff --git a/packages/desktop-client/src/components/settings/index.tsx b/packages/desktop-client/src/components/settings/index.tsx index 2f7ef5ada70ced36938eda5739c96e19f1dd257e..800715b11799fc39bceaa9118c8d4e9832dcb6ec 100644 --- a/packages/desktop-client/src/components/settings/index.tsx +++ b/packages/desktop-client/src/components/settings/index.tsx @@ -1,4 +1,3 @@ -// @ts-strict-ignore import React, { type ReactNode, useEffect } from 'react'; import { media } from 'glamor'; @@ -58,7 +57,7 @@ function About() { })}`} data-vrt-mask > - <Text>Client version: v{window.Actual.ACTUAL_VERSION}</Text> + <Text>Client version: v{window.Actual?.ACTUAL_VERSION}</Text> <Text>Server version: {version}</Text> {isOutdated ? ( <ExternalLink @@ -140,7 +139,7 @@ export function Settings() { <Page title="Settings" style={{ - backgroundColor: isNarrowWidth && theme.mobilePageBackground, + backgroundColor: isNarrowWidth ? theme.mobilePageBackground : undefined, marginInline: floatingSidebar && !isNarrowWidth ? 'auto' : 0, }} > diff --git a/packages/desktop-client/src/gocardless.ts b/packages/desktop-client/src/gocardless.ts index 809c9f86c6edbc0b386ef6304a23b5834137a52f..8277f18dadaa444e5c04df7502f9f52d08dcbd9f 100644 --- a/packages/desktop-client/src/gocardless.ts +++ b/packages/desktop-client/src/gocardless.ts @@ -1,4 +1,3 @@ -// @ts-strict-ignore import type { pushModal as pushModalAction } from 'loot-core/src/client/actions/modals'; import { send } from 'loot-core/src/platform/client/fetch'; import { type GoCardlessToken } from 'loot-core/src/types/models'; @@ -24,7 +23,7 @@ function _authorize( if ('error' in resp) return resp; const { link, requisitionId } = resp; - window.Actual.openURLInBrowser(link); + window.Actual?.openURLInBrowser(link); return send('gocardless-poll-web-token', { upgradingAccountId, diff --git a/packages/desktop-client/src/hooks/useFeatureFlag.ts b/packages/desktop-client/src/hooks/useFeatureFlag.ts index 5550cfed2cd0f17084c21e036abdd244f903ef8c..c3d3fa1376f0b31e84f1561794658a4ada228ebf 100644 --- a/packages/desktop-client/src/hooks/useFeatureFlag.ts +++ b/packages/desktop-client/src/hooks/useFeatureFlag.ts @@ -1,4 +1,3 @@ -// @ts-strict-ignore import { useSelector } from 'react-redux'; import { type State } from 'loot-core/src/client/state-types'; diff --git a/packages/desktop-client/src/plaid.js b/packages/desktop-client/src/plaid.js index 7dfd53804b51367a62580062b0b552f273b9dc90..7f54ca3528005eed14dae2ed1db342fcb37fbbb0 100644 --- a/packages/desktop-client/src/plaid.js +++ b/packages/desktop-client/src/plaid.js @@ -10,7 +10,7 @@ function _authorize(pushModal, plaidToken, { onSuccess, onClose }) { if (plaidToken) { url = url + '&plaidToken=' + plaidToken; } - window.Actual.openURLInBrowser(url); + window.Actual?.openURLInBrowser(url); const { error, data } = await send('poll-web-token', { token }); diff --git a/packages/desktop-client/src/tokens.ts b/packages/desktop-client/src/tokens.ts index f090391c2d39f29dd0102851158eda8ff6775b75..9c5d1facabe8c97e3c48481a957023abc627fb3b 100644 --- a/packages/desktop-client/src/tokens.ts +++ b/packages/desktop-client/src/tokens.ts @@ -1,4 +1,3 @@ -// @ts-strict-ignore enum BreakpointNames { small = 'small', medium = 'medium', @@ -27,7 +26,10 @@ type BreakpointsPx = { // } export const tokens: BreakpointsPx = Object.entries( breakpoints, -).reduce<BreakpointsPx>((acc, [key, val]) => { - acc[`breakpoint_${key}`] = `${val}px`; - return acc; -}, {} as BreakpointsPx); +).reduce<BreakpointsPx>( + (acc, [key, val]) => ({ + ...acc, + [`breakpoint_${key}`]: `${val}px`, + }), + {} as BreakpointsPx, +); diff --git a/packages/desktop-client/src/util/versions.ts b/packages/desktop-client/src/util/versions.ts index 291d236403fe4cfec0637ff86edc505518d1d05b..09427e15f2c7cff409bf4ee3eaf5529eb8bd357d 100644 --- a/packages/desktop-client/src/util/versions.ts +++ b/packages/desktop-client/src/util/versions.ts @@ -30,7 +30,7 @@ export async function getLatestVersion(): Promise<string | 'unknown'> { const json = await response.json(); const tags = json .map(t => t.name) - .concat([`v${window.Actual.ACTUAL_VERSION}`]); + .concat([`v${window.Actual?.ACTUAL_VERSION}`]); tags.sort(cmpSemanticVersion); return tags[tags.length - 1]; @@ -41,7 +41,7 @@ export async function getLatestVersion(): Promise<string | 'unknown'> { } export async function getIsOutdated(latestVersion: string): Promise<boolean> { - const clientVersion = window.Actual.ACTUAL_VERSION; + const clientVersion = window.Actual?.ACTUAL_VERSION; if (latestVersion === 'unknown') { return Promise.resolve(false); } diff --git a/upcoming-release-notes/2403.md b/upcoming-release-notes/2403.md new file mode 100644 index 0000000000000000000000000000000000000000..9a392343f7b09a54fd382837fb751d7a5ea6fdaf --- /dev/null +++ b/upcoming-release-notes/2403.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [MatissJanis] +--- + +Move some TypeScript files to strict mode