Skip to content

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

@FabrizioFerrari-ILS

Description

@FabrizioFerrari-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

Labels

bugSomething isn't workingtypescriptTypeScript-related pain point

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions