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
|
// 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
|
// for information about these interfaces
|
||||||
declare global {
|
declare global {
|
||||||
namespace App {
|
namespace App {
|
||||||
type Error = {
|
interface Error {
|
||||||
code: ErrorCode;
|
code: ErrorCode;
|
||||||
message?: string | undefined;
|
message?: string | undefined;
|
||||||
details?: string | undefined;
|
details?: string | undefined;
|
||||||
} | APIError
|
}
|
||||||
// interface Locals {}
|
// interface Locals {}
|
||||||
// interface PageData {}
|
// interface PageData {}
|
||||||
// interface Platform {}
|
// 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 {};
|
export {};
|
||||||
|
|
|
@ -11,7 +11,7 @@ export const load = async ({ params }) => {
|
||||||
return resp;
|
return resp;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if ((e as APIError).code === ErrorCode.UserNotFound) {
|
if ((e as APIError).code === ErrorCode.UserNotFound) {
|
||||||
error(404, e as APIError);
|
error(404, e as App.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -14,9 +14,9 @@ export const load = async ({ params }) => {
|
||||||
(e as APIError).code === ErrorCode.UserNotFound ||
|
(e as APIError).code === ErrorCode.UserNotFound ||
|
||||||
(e as APIError).code === ErrorCode.MemberNotFound
|
(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,
|
pronouns: pronouns.autocomplete,
|
||||||
flags,
|
flags,
|
||||||
};
|
};
|
||||||
} catch (e) {
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
if ("code" in e) error(500, e as APIError);
|
} catch (e: any) {
|
||||||
|
if ("code" in e) error(500, e as App.Error);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}) satisfies LayoutLoad;
|
}) satisfies LayoutLoad;
|
||||||
|
|
|
@ -21,8 +21,9 @@ export const load = async ({ params }) => {
|
||||||
pronouns: pronouns.autocomplete,
|
pronouns: pronouns.autocomplete,
|
||||||
flags,
|
flags,
|
||||||
};
|
};
|
||||||
} catch (e) {
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
if ("code" in e) error(500, e as APIError);
|
} catch (e: any) {
|
||||||
|
if ("code" in e) error(500, e as App.Error);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,7 @@ export const load = async ({ params }) => {
|
||||||
redirect(303, `/@${resp.name}`);
|
redirect(303, `/@${resp.name}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if ((e as APIError).code === ErrorCode.UserNotFound) {
|
if ((e as APIError).code === ErrorCode.UserNotFound) {
|
||||||
error(404, e as APIError);
|
error(404, e as App.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -23,7 +23,7 @@ export const load = async ({ params }) => {
|
||||||
(e as APIError).code === ErrorCode.InvalidToken ||
|
(e as APIError).code === ErrorCode.InvalidToken ||
|
||||||
(e as APIError).code === ErrorCode.NotOwnMember
|
(e as APIError).code === ErrorCode.NotOwnMember
|
||||||
) {
|
) {
|
||||||
error(403, e as APIError);
|
error(403, e as App.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -14,7 +14,7 @@ export const load = async () => {
|
||||||
(e as APIError).code === ErrorCode.Forbidden ||
|
(e as APIError).code === ErrorCode.Forbidden ||
|
||||||
(e as APIError).code === ErrorCode.InvalidToken
|
(e as APIError).code === ErrorCode.InvalidToken
|
||||||
) {
|
) {
|
||||||
error(403, e as APIError);
|
error(403, e as App.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
//@ts-ignore
|
||||||
import { html } from "./about.md";
|
import { html } from "./about.md";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
|
//@ts-ignore
|
||||||
import { html } from "./changelog.md";
|
import { html } from "./changelog.md";
|
||||||
import { CURRENT_CHANGELOG } from "$lib/store";
|
import { CURRENT_CHANGELOG } from "$lib/store";
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
//@ts-ignore
|
||||||
import { html } from "./privacy.md";
|
import { html } from "./privacy.md";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
//@ts-ignore
|
||||||
import { html } from "./terms.md";
|
import { html } from "./terms.md";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { PUBLIC_BASE_URL } from "$env/static/public";
|
import { PUBLIC_BASE_URL } from "$env/static/public";
|
||||||
import type { PageData } from "../../$types";
|
import type { PageData } from "./$types";
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,6 @@ export const load = async () => {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if ((e as APIError).code === ErrorCode.NotFound) return { exportData: null };
|
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