Skip to content

Commit 64dd2b1

Browse files
committed
docs, test
1 parent 6b9a1f0 commit 64dd2b1

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

packages/svelte/src/internal/server/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ export function element(payload, tag, attributes_fn, children_fn) {
9696
export let on_destroy = [];
9797

9898
/**
99-
* @template {Record<string, any>} TProps
100-
*
101-
* @param {import('svelte').Component<TProps> | import('svelte').ComponentType<import('svelte').SvelteComponent<TProps>>} component
102-
* @param {{ props: Omit<TProps, '$$slots' | '$$events'>; context?: Map<any, any> }} options
99+
* Only available on the server and when compiling with the `server` option.
100+
* Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app.
101+
* @template {Record<string, any>} Props
102+
* @param {import('svelte').Component<Props> | import('svelte').ComponentType<import('svelte').SvelteComponent<Props>>} component
103+
* @param {{ props: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any> }} options
103104
* @returns {import('#server').RenderOutput}
104105
*/
105106
export function render(component, options) {

packages/svelte/tests/types/component.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
hydrate,
99
type Component
1010
} from 'svelte';
11+
import { render } from 'svelte/server';
1112

1213
SvelteComponent.element === HTMLElement;
1314

@@ -148,6 +149,14 @@ hydrate(NewComponent, {
148149
recover: false
149150
});
150151

152+
render(NewComponent, {
153+
props: {
154+
prop: 'foo',
155+
// @ts-expect-error
156+
x: ''
157+
}
158+
});
159+
151160
// --------------------------------------------------------------------------- interop
152161

153162
const AsLegacyComponent = asClassComponent(newComponent);
@@ -256,3 +265,12 @@ hydrate(functionComponent, {
256265
binding: true
257266
}
258267
});
268+
269+
render(functionComponent, {
270+
props: {
271+
binding: true,
272+
readonly: 'foo',
273+
// @ts-expect-error
274+
x: ''
275+
}
276+
});

0 commit comments

Comments
 (0)