fix: remove PageServerLoad annotations from disabled routes
The auth and profile layout redirects break SvelteKit's type generation for child page loads, causing false-positive type errors where PageData requires `user` from the root layout.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import type { Actions, PageServerLoad } from './$types.js';
|
||||
import type { Actions } from './$types.js';
|
||||
import { fail, redirect } from '@sveltejs/kit';
|
||||
import { apiFetch, ApiClientError } from '$lib/api/client.js';
|
||||
import type { AuthData, MessageData } from '$lib/api/types.js';
|
||||
import { setAuthCookies } from '$lib/auth/cookies.js';
|
||||
|
||||
export const load: PageServerLoad = async ({ locals, url }) => {
|
||||
export const load = async ({ locals, url }: { locals: App.Locals; url: URL }) => {
|
||||
if (locals.user) redirect(302, '/');
|
||||
return {
|
||||
redirectTo: url.searchParams.get('redirect') ?? '/'
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { Actions, PageServerLoad } from './$types.js';
|
||||
import type { Actions } from './$types.js';
|
||||
import { fail, redirect } from '@sveltejs/kit';
|
||||
import { apiFetch, ApiClientError } from '$lib/api/client.js';
|
||||
import type { AuthData } from '$lib/api/types.js';
|
||||
import { setAuthCookies } from '$lib/auth/cookies.js';
|
||||
|
||||
export const load: PageServerLoad = async ({ locals }) => {
|
||||
export const load = async ({ locals }: { locals: App.Locals }) => {
|
||||
if (locals.user) redirect(302, '/');
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Actions, PageServerLoad } from './$types.js';
|
||||
import type { Actions } from './$types.js';
|
||||
import { fail } from '@sveltejs/kit';
|
||||
import { requireAuth } from '$lib/auth/guard.js';
|
||||
import { serverFetch } from '$lib/api/client.server.js';
|
||||
@@ -7,9 +7,8 @@ import { clearAuthCookies } from '$lib/auth/cookies.js';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { ProfileData } from '$lib/api/types.js';
|
||||
|
||||
export const load: PageServerLoad = async (event) => {
|
||||
export const load = async (event: Parameters<import('./$types.js').PageServerLoad>[0]) => {
|
||||
requireAuth(event);
|
||||
|
||||
const res = await serverFetch<ProfileData>('/users/me', event.cookies, { fetch: event.fetch });
|
||||
return { profile: res.data };
|
||||
};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { Actions, PageServerLoad } from './$types.js';
|
||||
import type { Actions } from './$types.js';
|
||||
import { fail } from '@sveltejs/kit';
|
||||
import { requireAuth } from '$lib/auth/guard.js';
|
||||
import { serverFetch } from '$lib/api/client.server.js';
|
||||
import { ApiClientError } from '$lib/api/client.js';
|
||||
import type { TOTPSetupData, MessageData } from '$lib/api/types.js';
|
||||
|
||||
export const load: PageServerLoad = async (event) => {
|
||||
export const load = async (event: Parameters<import('./$types.js').PageServerLoad>[0]) => {
|
||||
requireAuth(event);
|
||||
return {};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user