svelte icon indicating copy to clipboard operation
svelte copied to clipboard

docs: clarify svelte:component migration, avoids common gotcha

Open rgon opened this issue 4 months ago • 1 comments

Clarify docs to specify that, while svelte:component is no longer needed and deprecated, capitalizing the component variable name is required to avoid mismatching types.

Avoids users doing the same gotcha that I stumbled upon, it will be a common oversight when refactoring existing codebases: #13795

As evidenced in these docs themselves (corrected):

...
	let component: Component<{ foo: string }> = $state(
		Math.random() ? ComponentA : ComponentB
	);
</script>

<svelte:component this={component} foo="bar" />

rgon avatar Oct 23 '24 16:10 rgon