Skip to content

[Svelte 5] Name conflict between property and slot #2105

Open
@ff-ils

Description

@ff-ils

When converting to Svelte 5, I think there is a problem due to the same name used for properties and slots. For example, this works:

<FileUploaderDropContainer bind:files>
	<svelte:fragment slot="labelText">
		<Icon icon="fluent:document-add-48-regular" />
		Add file
		<br />
		(1GB max)
	</svelte:fragment>
</FileUploaderDropContainer>

If I convert the slot to a snippet

<FileUploaderDropContainer bind:files>
	{#snippet labelText()}
		<Icon icon="fluent:document-add-48-regular" />
		Add file
		<br />
		(1GB max)
	{/snippet}
</FileUploaderDropContainer>

I get this error on "labelText"

Type '() => any' is not assignable to type 'string'.ts(2322)

probably because Svelte engine tries to assign the snippet to the property.
It would be a great effort to migrate all components to Svelte 5 snippets, but avoiding name conflicts would allow to use them with the new syntax, keeping slots internally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions