Open
Description
Describe the bug
<script lang="ts">
let a: HTMLParagraphElement;
let b: HTMLParagraphElement | undefined = undefined;
</script>
<p bind:this={a} bind:this={b}></p>
// Variable 'a' is used before being assigned.ts(2454)
const a2 = $derived(a.children);
// Property 'children' does not exist on type 'never'.ts(2339)
const b2 = $derived(b?.children);
// let a2: HTMLCollection
$: a2 = a.children;
// let b2: HTMLCollection | undefined
$: b2 = b?.children;
Reproduction
See above.
Logs
No response
System Info
System:
OS: macOS 14.6.1
CPU: (10) arm64 Apple M1 Pro
Memory: 665.30 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.8.0 - ~/.local/state/fnm_multishells/8044_1725946328522/bin/node
npm: 10.8.2 - ~/.local/state/fnm_multishells/8044_1725946328522/bin/npm
pnpm: 9.9.0 - ~/.local/state/fnm_multishells/8044_1725946328522/bin/pnpm
Browsers:
Chrome: 128.0.6613.120
Edge: 128.0.2739.67
Safari: 17.6
npmPackages:
svelte: 5.0.0-next.244 => 5.0.0-next.244
Severity
annoyance