fix(frontend): fix type errors

This commit is contained in:
sam 2023-12-30 15:13:24 +01:00
parent 00abe1cb32
commit ac603ac18e
No known key found for this signature in database
GPG Key ID: B4EF20DDE721CAA1
15 changed files with 39 additions and 34 deletions

25
frontend/src/app.d.ts vendored
View File

@ -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 {};

View File

@ -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;

View File

@ -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);
} }
}; };

View File

@ -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;

View File

@ -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;
} }
}; };

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -1,4 +1,5 @@
<script lang="ts"> <script lang="ts">
//@ts-ignore
import { html } from "./about.md"; import { html } from "./about.md";
</script> </script>

View File

@ -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";

View File

@ -1,4 +1,5 @@
<script lang="ts"> <script lang="ts">
//@ts-ignore
import { html } from "./privacy.md"; import { html } from "./privacy.md";
</script> </script>

View File

@ -1,4 +1,5 @@
<script lang="ts"> <script lang="ts">
//@ts-ignore
import { html } from "./terms.md"; import { html } from "./terms.md";
</script> </script>

View File

@ -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;

View File

@ -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);
} }
}; };

18
frontend/src/svelte-hcaptcha.d.ts vendored Normal file
View File

@ -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;
}