What is the correct TypeScript type for the `children` property in Svelte 5? - Stack Overflow
In Svelte 5 it now retrieves children from the the $props()
rune. I wasn't able to find any documentation stating how the props reserved children
property should be typed and the type is not included in the $props()
rune by default.
<script lang="ts">
import type { Snippet } from 'svelte';
interface Props {
children: ?????; // What do I type this as?
}
const { children }: Props = $props();
</script>
<div>
{@render children?.()}
</div>
In Svelte 5 it now retrieves children from the the $props()
rune. I wasn't able to find any documentation stating how the props reserved children
property should be typed and the type is not included in the $props()
rune by default.
<script lang="ts">
import type { Snippet } from 'svelte';
interface Props {
children: ?????; // What do I type this as?
}
const { children }: Props = $props();
</script>
<div>
{@render children?.()}
</div>
Share
Improve this question
asked 15 hours ago
Daniel TononDaniel Tonon
10.2k5 gold badges65 silver badges67 bronze badges
1 Answer
Reset to default 0children
is typed as Snippet
(imported from 'svelte'
)
<script lang="ts">
import type { Snippet } from 'svelte';
interface Props {
children: Snippet;
}
const { children }: Props = $props();
</script>
<div>
{@render children?.()}
</div>
最新文章
- 纳德拉:微软所有软件将转向包年订户模式
- c# - Having problems with a unity learn tutorial regarding Top-Level Statements - Stack Overflow
- powershell - Windows AutoPilot - Set Auto Login - Stack Overflow
- Unable to Access Event Data via Eventbrite API - 404 NOT_FOUND Error - Stack Overflow
- TGUI Using raylib backend with cmake - Stack Overflow
- How to Implement Smooth Pinch-to-Zoom Animation similar to Photos application (iphone) in Flutter? - Stack Overflow
- java - mac update sequoia 15.1 or 15.2 not work UniversalJavaApplicationStub - Stack Overflow
- jetpack compose navigation - SaveStateHandle.toRoute cannot be called in viewModel in kmp project - Stack Overflow
- intellij http client - How to use in place variable within handler scripts? - Stack Overflow
- python - Could NOT find Python3 during cmake - Stack Overflow
- python - testing the output of seaborn figure level plots - Stack Overflow
- docker - Python Telegram bot freezes when run by Airflow - Stack Overflow
- mapping - How to display drawdown contours calculated with the Theis equation to display on an interactive map in Dash with Pyth
- I can't receive messages through my webhook with Whatsapp Cloud API - Stack Overflow
- c++ - Member of struct constructed twice in custom constructor? - Stack Overflow
- tsconfig - Is there a typescript compiler option that prevents implicit widening from readonly properties to readwrite? - Stack
- Conflicting dependencies while installing torch==1.10.0, torchaudio==0.10.0, and torchvision==0.11.0 in my Python environment -