Skip to content

Commit

Permalink
tsc error fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
doggan committed Sep 7, 2023
1 parent e8a8b9a commit 1b483df
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
4 changes: 3 additions & 1 deletion packages/desktop-client/src/components/FatalError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ 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>
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function compileMessage(
if (actions[actionName]) {
setLoading(true);
await actions[actionName]();
onRemove();
onRemove?.();
}
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import { ConfirmPasswordForm } from './ConfirmPasswordForm';

export default function Bootstrap() {
let dispatch = useDispatch();
let [error, setError] = useState(null);
let [error, setError] = useState<string | null>(null);

let { checked } = useBootstrapped();

function getErrorMessage(error) {
function getErrorMessage(error: string) {
switch (error) {
case 'invalid-password':
return 'Password cannot be empty';
Expand All @@ -34,7 +34,7 @@ export default function Bootstrap() {
}
}

async function onSetPassword(password) {
async function onSetPassword(password: string) {
setError(null);
let { error } = await send('subscribe-bootstrap', { password });

Expand Down Expand Up @@ -94,7 +94,7 @@ export default function Bootstrap() {
</Button>
}
onSetPassword={onSetPassword}
onError={setError}
onError={err => setError(err)}
/>
</View>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { ConfirmPasswordForm } from './ConfirmPasswordForm';

export default function ChangePassword() {
let navigate = useNavigate();
let [error, setError] = useState(null);
let [msg, setMessage] = useState(null);
let [error, setError] = useState<string | null>(null);
let [msg, setMessage] = useState<string | null>(null);

function getErrorMessage(error) {
function getErrorMessage(error: string) {
switch (error) {
case 'invalid-password':
return 'Password cannot be empty';
Expand All @@ -29,7 +29,7 @@ export default function ChangePassword() {
}
}

async function onSetPassword(password) {
async function onSetPassword(password: string) {
setError(null);
let { error } = await send('subscribe-change-password', { password });

Expand Down Expand Up @@ -93,7 +93,7 @@ export default function ChangePassword() {
</Button>
}
onSetPassword={onSetPassword}
onError={setError}
onError={err => setError(err)}
/>
</View>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import React, { type ChangeEvent, useState } from 'react';
import React, { type ChangeEvent, type ReactNode, useState } from 'react';

import { ButtonWithLoading } from '../../common/Button';
import { BigInput } from '../../common/Input';
import View from '../../common/View';

export function ConfirmPasswordForm({ buttons, onSetPassword, onError }) {
type ConfirmPasswordFormProps = {
buttons: ReactNode;
onSetPassword: (password: string) => void;
onError: (error: string) => void;
};

export function ConfirmPasswordForm({
buttons,
onSetPassword,
onError,
}: ConfirmPasswordFormProps) {
let [password1, setPassword1] = useState('');
let [password2, setPassword2] = useState('');
let [showPassword, setShowPassword] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function ScheduleAmountCell({ amount, op }) {
<Text
style={{
flex: 1,
color: num > 0 ? colors.g5 : null,
color: num > 0 ? colors.g5 : undefined,
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
Expand Down

0 comments on commit 1b483df

Please sign in to comment.