svelte icon indicating copy to clipboard operation
svelte copied to clipboard

No error for `@render undefined` if snippet function is state

Open rChaoz opened this issue 6 months ago • 0 comments

Describe the bug

Currently, @render has no problem if it the snippet function is undefined if it's a state/prop, which is weird since it is a function call. Considering the {@render func?.() syntax is supported, it should throw.

Case 1:

<script>
  let func = $state()
  $effect(() => {
    console.log(func === undefined) // true
  });
</script>

This doesn't throw: {@render func()}

Case 2:

<script>
  let func
  console.log(func === undefined) // true
</script>

This is an error: {@render func()}

Severity

annoyance

rChaoz avatar Aug 23 '24 19:08 rChaoz