Skip to content

Commit

Permalink
fix default hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Konstantinov committed Nov 16, 2024
1 parent 5289247 commit a4f4b0b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
11 changes: 6 additions & 5 deletions packages/kit/src/exports/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ export interface ActionFailure<T extends Record<string, unknown> | undefined = u
[uniqueSymbol]: true; // necessary or else UnpackValidationError could wrongly unpack objects with the same shape as ActionFailure
}

type UnpackValidationError<T> = T extends ActionFailure<infer X>
? X
: T extends void
? undefined // needs to be undefined, because void will corrupt union type
: T;
type UnpackValidationError<T> =
T extends ActionFailure<infer X>
? X
: T extends void
? undefined // needs to be undefined, because void will corrupt union type
: T;

/**
* This object is passed to the `adapt` function of adapters.
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/runtime/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ async function load_route({ id, invalidating, url, params, route, preload }) {
server_data_node: create_data_node(
// server_data_node is undefined if it wasn't reloaded from the server;
// and if current loader uses server data, we want to reuse previous data.
server_data_node === undefined && loader[0] ? { type: 'skip' } : server_data_node ?? null,
server_data_node === undefined && loader[0] ? { type: 'skip' } : (server_data_node ?? null),
loader[0] ? previous?.server : undefined
)
});
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/src/runtime/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class Server {

this.#options.hooks = {
handle: module.handle || (({ event, resolve }) => resolve(event)),
handlePageData: module.handlePageData || (({ pageData, resolve }) => resolve(pageData)),
handlePageData: module.handlePageData || (() => void null),
handleError: module.handleError || (({ error }) => console.error(error)),
handleFetch: module.handleFetch || (({ request, fetch }) => fetch(request)),
reroute: module.reroute || (() => {})
Expand All @@ -80,7 +80,7 @@ export class Server {
handle: () => {
throw error;
},
handlePageData: ({ pageData, resolve }) => resolve(pageData),
handlePageData: () => void null,
handleError: ({ error }) => console.error(error),
handleFetch: ({ request, fetch }) => fetch(request),
reroute: () => {}
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/runtime/server/page/load_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export function create_universal_fetch(event, state, fetched, csr, resolve_opts)
}
} else {
// simulate CORS errors and "no access to body in no-cors mode" server-side for consistency with client-side behaviour
const mode = input instanceof Request ? input.mode : init?.mode ?? 'cors';
const mode = input instanceof Request ? input.mode : (init?.mode ?? 'cors');
if (mode === 'no-cors') {
response = new Response('', {
status: response.status,
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/runtime/server/page/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export async function render_response({

const form_value =
action_result?.type === 'success' || action_result?.type === 'failure'
? action_result.data ?? null
? (action_result.data ?? null)
: null;

/** @type {string} */
Expand Down

0 comments on commit a4f4b0b

Please sign in to comment.