Skip to content

chore: fix types for universal and server fields #13542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/kit/src/runtime/server/page/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function check_named_default_separate(actions) {

/**
* @param {import('@sveltejs/kit').RequestEvent} event
* @param {NonNullable<import('types').SSRNode['server']['actions']>} actions
* @param {NonNullable<import('types').ServerNode['actions']>} actions
* @throws {Redirect | HttpError | SvelteKitError | Error}
*/
async function call_action(event, actions) {
Expand Down
44 changes: 23 additions & 21 deletions packages/kit/src/types/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,27 @@ export interface SSRComponent {

export type SSRComponentLoader = () => Promise<SSRComponent>;

export interface UniversalNode {
load?: Load;
prerender?: PrerenderOption;
ssr?: boolean;
csr?: boolean;
trailingSlash?: TrailingSlash;
config?: any;
entries?: PrerenderEntryGenerator;
}

export interface ServerNode {
load?: ServerLoad;
prerender?: PrerenderOption;
ssr?: boolean;
csr?: boolean;
trailingSlash?: TrailingSlash;
actions?: Actions;
config?: any;
entries?: PrerenderEntryGenerator;
}

export interface SSRNode {
component: SSRComponentLoader;
/** index into the `nodes` array in the generated `client/app.js`. */
Expand All @@ -377,29 +398,10 @@ export interface SSRNode {
/** inlined styles. */
inline_styles?(): MaybePromise<Record<string, string>>;

universal: {
load?: Load;
prerender?: PrerenderOption;
ssr?: boolean;
csr?: boolean;
trailingSlash?: TrailingSlash;
config?: any;
entries?: PrerenderEntryGenerator;
};

server: {
load?: ServerLoad;
prerender?: PrerenderOption;
ssr?: boolean;
csr?: boolean;
trailingSlash?: TrailingSlash;
actions?: Actions;
config?: any;
entries?: PrerenderEntryGenerator;
};

universal_id?: string;
server_id?: string;
universal?: UniversalNode;
server?: ServerNode;
}

export type SSRNodeLoader = () => Promise<SSRNode>;
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/utils/options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @template {'prerender' | 'ssr' | 'csr' | 'trailingSlash' | 'entries'} Option
* @template {(import('types').SSRNode['universal'] | import('types').SSRNode['server'])[Option]} Value
* @template {(import('types').UniversalNode | import('types').ServerNode)[Option]} Value
*
* @param {Array<import('types').SSRNode | undefined>} nodes
* @param {Option} option
Expand Down
44 changes: 23 additions & 21 deletions packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,27 @@ declare module '@sveltejs/kit' {

type SSRComponentLoader = () => Promise<SSRComponent>;

interface UniversalNode {
load?: Load;
prerender?: PrerenderOption;
ssr?: boolean;
csr?: boolean;
trailingSlash?: TrailingSlash;
config?: any;
entries?: PrerenderEntryGenerator;
}

interface ServerNode {
load?: ServerLoad;
prerender?: PrerenderOption;
ssr?: boolean;
csr?: boolean;
trailingSlash?: TrailingSlash;
actions?: Actions;
config?: any;
entries?: PrerenderEntryGenerator;
}

interface SSRNode {
component: SSRComponentLoader;
/** index into the `nodes` array in the generated `client/app.js`. */
Expand All @@ -1855,29 +1876,10 @@ declare module '@sveltejs/kit' {
/** inlined styles. */
inline_styles?(): MaybePromise<Record<string, string>>;

universal: {
load?: Load;
prerender?: PrerenderOption;
ssr?: boolean;
csr?: boolean;
trailingSlash?: TrailingSlash;
config?: any;
entries?: PrerenderEntryGenerator;
};

server: {
load?: ServerLoad;
prerender?: PrerenderOption;
ssr?: boolean;
csr?: boolean;
trailingSlash?: TrailingSlash;
actions?: Actions;
config?: any;
entries?: PrerenderEntryGenerator;
};

universal_id?: string;
server_id?: string;
universal?: UniversalNode;
server?: ServerNode;
}

type SSRNodeLoader = () => Promise<SSRNode>;
Expand Down
Loading