fix(frontend): fix type errors
This commit is contained in:
parent
00abe1cb32
commit
ac603ac18e
|
@ -1,38 +1,19 @@
|
|||
// See https://kit.svelte.dev/docs/types#app
|
||||
|
||||
import type { APIError, ErrorCode } from "$lib/api/entities";
|
||||
import type { ErrorCode } from "$lib/api/entities";
|
||||
|
||||
// for information about these interfaces
|
||||
declare global {
|
||||
namespace App {
|
||||
type Error = {
|
||||
interface Error {
|
||||
code: ErrorCode;
|
||||
message?: string | undefined;
|
||||
details?: string | undefined;
|
||||
} | APIError
|
||||
}
|
||||
// interface Locals {}
|
||||
// interface PageData {}
|
||||
// interface Platform {}
|
||||
}
|
||||
}
|
||||
|
||||
declare module "svelte-hcaptcha" {
|
||||
import type { SvelteComponent } from "svelte";
|
||||
|
||||
export interface HCaptchaProps {
|
||||
sitekey?: string;
|
||||
apihost?: string;
|
||||
hl?: string;
|
||||
reCaptchaCompat?: boolean;
|
||||
theme?: CaptchaTheme;
|
||||
size?: string;
|
||||
}
|
||||
|
||||
declare class HCaptcha extends SvelteComponent {
|
||||
$$prop_def: HCaptchaProps;
|
||||
}
|
||||
|
||||
export default HCaptcha;
|
||||
}
|
||||
|
||||
export {};
|
||||
|
|
|
@ -11,7 +11,7 @@ export const load = async ({ params }) => {
|
|||
return resp;
|
||||
} catch (e) {
|
||||
if ((e as APIError).code === ErrorCode.UserNotFound) {
|
||||
error(404, e as APIError);
|
||||
error(404, e as App.Error);
|
||||
}
|
||||
|
||||
throw e;
|
||||
|
|
|
@ -14,9 +14,9 @@ export const load = async ({ params }) => {
|
|||
(e as APIError).code === ErrorCode.UserNotFound ||
|
||||
(e as APIError).code === ErrorCode.MemberNotFound
|
||||
) {
|
||||
error(404, e as APIError);
|
||||
error(404, e as App.Error);
|
||||
}
|
||||
|
||||
error(500, e as APIError);
|
||||
error(500, e as App.Error);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -41,8 +41,9 @@ export const load = (async ({ params }) => {
|
|||
pronouns: pronouns.autocomplete,
|
||||
flags,
|
||||
};
|
||||
} catch (e) {
|
||||
if ("code" in e) error(500, e as APIError);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (e: any) {
|
||||
if ("code" in e) error(500, e as App.Error);
|
||||
throw e;
|
||||
}
|
||||
}) satisfies LayoutLoad;
|
||||
|
|
|
@ -21,8 +21,9 @@ export const load = async ({ params }) => {
|
|||
pronouns: pronouns.autocomplete,
|
||||
flags,
|
||||
};
|
||||
} catch (e) {
|
||||
if ("code" in e) error(500, e as APIError);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (e: any) {
|
||||
if ("code" in e) error(500, e as App.Error);
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@ export const load = async ({ params }) => {
|
|||
redirect(303, `/@${resp.name}`);
|
||||
} catch (e) {
|
||||
if ((e as APIError).code === ErrorCode.UserNotFound) {
|
||||
error(404, e as APIError);
|
||||
error(404, e as App.Error);
|
||||
}
|
||||
|
||||
throw e;
|
||||
|
|
|
@ -23,7 +23,7 @@ export const load = async ({ params }) => {
|
|||
(e as APIError).code === ErrorCode.InvalidToken ||
|
||||
(e as APIError).code === ErrorCode.NotOwnMember
|
||||
) {
|
||||
error(403, e as APIError);
|
||||
error(403, e as App.Error);
|
||||
}
|
||||
|
||||
throw e;
|
||||
|
|
|
@ -14,7 +14,7 @@ export const load = async () => {
|
|||
(e as APIError).code === ErrorCode.Forbidden ||
|
||||
(e as APIError).code === ErrorCode.InvalidToken
|
||||
) {
|
||||
error(403, e as APIError);
|
||||
error(403, e as App.Error);
|
||||
}
|
||||
|
||||
throw e;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<script lang="ts">
|
||||
//@ts-ignore
|
||||
import { html } from "./about.md";
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
//@ts-ignore
|
||||
import { html } from "./changelog.md";
|
||||
import { CURRENT_CHANGELOG } from "$lib/store";
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<script lang="ts">
|
||||
//@ts-ignore
|
||||
import { html } from "./privacy.md";
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<script lang="ts">
|
||||
//@ts-ignore
|
||||
import { html } from "./terms.md";
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { PUBLIC_BASE_URL } from "$env/static/public";
|
||||
import type { PageData } from "../../$types";
|
||||
import type { PageData } from "./$types";
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
|
|
|
@ -10,6 +10,6 @@ export const load = async () => {
|
|||
} catch (e) {
|
||||
if ((e as APIError).code === ErrorCode.NotFound) return { exportData: null };
|
||||
|
||||
error(500, e as APIError);
|
||||
error(500, e as App.Error);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
declare module "svelte-hcaptcha" {
|
||||
import type { SvelteComponent } from "svelte";
|
||||
|
||||
export interface HCaptchaProps {
|
||||
sitekey?: string;
|
||||
apihost?: string;
|
||||
hl?: string;
|
||||
reCaptchaCompat?: boolean;
|
||||
theme?: CaptchaTheme;
|
||||
size?: string;
|
||||
}
|
||||
|
||||
declare class HCaptcha extends SvelteComponent {
|
||||
$$prop_def: HCaptchaProps;
|
||||
}
|
||||
|
||||
export default HCaptcha;
|
||||
}
|
Loading…
Reference in New Issue