Towards strict

This commit is contained in:
Manav Rathi 2024-05-24 19:46:02 +05:30
parent 367e09599d
commit acebb86fec
No known key found for this signature in database
7 changed files with 22 additions and 8 deletions

View file

@ -32,8 +32,11 @@ const AuthenticatorCodesPage = () => {
try {
const res = await getAuthCodes();
setCodes(res);
} catch (err) {
if (err.message === CustomError.KEY_MISSING) {
} catch (e) {
if (
e instanceof Error &&
e.message === CustomError.KEY_MISSING
) {
InMemoryStore.set(MS_KEYS.REDIRECT_URL, PAGES.AUTH);
router.push(PAGES.ROOT);
} else {

View file

@ -58,7 +58,10 @@ export const getAuthCodes = async (): Promise<Code[]> => {
});
return filteredAuthCodes;
} catch (e) {
if (e.message !== CustomError.AUTH_KEY_NOT_FOUND) {
if (
e instanceof Error &&
e.message !== CustomError.AUTH_KEY_NOT_FOUND
) {
log.error("get authenticator entities failed", e);
}
throw e;

View file

@ -12,7 +12,9 @@
"jsxImportSource": "@emotion/react",
"strict": false,
"strict": true,
"strictNullChecks": false,
"noImplicitAny": false,
/* Stricter than strict */
"noImplicitReturns": true,
"noUnusedParameters": true,

View file

@ -58,7 +58,8 @@ function SetPasswordForm(props: SetPasswordFormProps) {
setFieldError("confirm", t("PASSPHRASE_MATCH_ERROR"));
}
} catch (e) {
setFieldError("confirm", `${t("UNKNOWN_ERROR")} ${e.message}`);
const message = e instanceof Error ? e.message : "";
setFieldError("confirm", `${t("UNKNOWN_ERROR")} ${message}`);
} finally {
setLoading(false);
}

View file

@ -84,7 +84,8 @@ export default function SignUp({ router, appName, login }: SignUpProps) {
setLocalReferralSource(referral);
await sendOtt(appName, email);
} catch (e) {
setFieldError("confirm", `${t("UNKNOWN_ERROR")} ${e.message}`);
const message = e instanceof Error ? e.message : "";
setFieldError("confirm", `${t("UNKNOWN_ERROR")} ${message}`);
throw e;
}
try {

View file

@ -47,7 +47,8 @@ export default function VerifyTwoFactor(props: Props) {
for (let i = 0; i < 6; i++) {
otpInputRef.current?.focusPrevInput();
}
setFieldError("otp", `${t("UNKNOWN_ERROR")} ${e.message}`);
const message = e instanceof Error ? e.message : "";
setFieldError("otp", `${t("UNKNOWN_ERROR")} ${message}`);
}
setWaiting(false);
};

View file

@ -197,7 +197,10 @@ export default function Credentials({ appContext, appName }: PageProps) {
return keyAttributes;
}
} catch (e) {
if (e.message !== CustomError.TWO_FACTOR_ENABLED) {
if (
e instanceof Error &&
e.message !== CustomError.TWO_FACTOR_ENABLED
) {
log.error("getKeyAttributes failed", e);
}
throw e;