svelte-check-rs-repro-snippet-children Svelte Themes

Svelte Check Rs Repro Snippet Children

Repro: svelte-check-rs types untyped children prop as unknown instead of Snippet

svelte-check-rs bug: untyped children prop typed as unknown

Bug

When a component destructures children from $props() without an explicit type annotation and renders it via {@render children?.()}, svelte-check-rs types children as unknown instead of Snippet. This causes a false type error:

src/lib/Wrapper.svelte:5:12
Error: This expression is not callable. (ts(TS2349))

Native svelte-check correctly infers children as Snippet.

Minimal example

<!-- src/lib/Wrapper.svelte -->
<script lang="ts">
  let { children } = $props();
</script>
<div class="wrapper">
  {@render children?.()}  <!-- TS2349: not callable -->
</div>

Generated TypeScript (--emit-ts)

let { children } = ({} as __SvelteLoosen<Record<string, unknown>>);
// children: unknown

children?.();  // Error: unknown has no call signatures

The correct output should type children as Snippet based on the template usage.

Reproduce

pnpm install
npx svelte-check-rs

Workaround

Add an explicit type annotation:

<script lang="ts">
  import type { Snippet } from "svelte";
  let { children }: { children: Snippet } = $props();
</script>

Environment

  • svelte-check-rs 0.9.16
  • Svelte 5 / SvelteKit 2

Top categories

Loading Svelte Themes