Skip to content

Migration: svelte:component which is not direct a children of a block and require {@const} is improperly migrated #13469

Closed
@paoloricciuti

Description

@paoloricciuti

Describe the bug

<script>
	import Component from "./Component.svelte";
</script>

<Component>
	<div>
		<svelte:component this={true && Component} />
	</div>
</Component>

this get's migrated to

<script>
	import Component from "./Component.svelte";
</script>

<Component>
	<div>
		{@const SvelteComponent = true && Component}
		<SvelteComponent />
	</div>
</Component>

which is a compile error.

Also migrating this

<InputAutoComplete>
	<AutoCompleteItem>
		<svelte:component this={item.type === 'city' ? CityIcon : TrainIcon} />
	</AutoCompleteItem>
</InputAutoComplete>

results in this

<InputAutoComplete>
	<AutoCompleteItem>
		{@const SvelteComponent = item.type === 'city' ? CityIcon : TrainIcon}
		{@const SvelteComponent = item.type === 'city' ? CityIcon : TrainIcon}
		<SvelteComponent />
	</AutoCompleteItem>
</InputAutoComplete>

which is also a runtime error.

Reproduction

REPL

REPL2

Logs

No response

System Info

-

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions