Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svelte 5: Argument name conflict in generated code #10662

Closed
dangelomedinag opened this issue Feb 28, 2024 · 1 comment · Fixed by #10669
Closed

Svelte 5: Argument name conflict in generated code #10662

dangelomedinag opened this issue Feb 28, 2024 · 1 comment · Fixed by #10669
Assignees
Milestone

Comments

@dangelomedinag
Copy link

Describe the bug

<!-- App.svelte -->
<script>
	import Component from "./Component.svelte"
	let state = $state({name: "svelte"})
	function action(node, param) {
            $effect(() => { node.innerText = param.name })
	};
</script>

<input bind:value={state.name}/>
<div use:action={state}></div>
<Component {action} {state}></Component>
<!-- Component.svelte -->
<script>
	let {action, state} = $props()
</script>

<!-- ERROR: $$props.action is not a function -->
<div use:action={state}></div>

if we define function action(){} inside the component, it works.

Reproduction

link

Logs

$$props.action is not a function

System Info

v5.0.0-next.68

Severity

annoyance

@brunnerh
Copy link
Member

brunnerh commented Feb 28, 2024

Generated code has conflicting argument name:

$.action(div, ($$node, $$props) => $$props.action($$node, $$props), () => $$props.state);
//                     ^conflict   ^intends to reference component props

@dangelomedinag dangelomedinag changed the title Svelte 5: $$props.action is not a function when passing an action as prop Svelte 5: Argument name conflict in generated code Feb 28, 2024
@dummdidumm dummdidumm added this to the 5.0 milestone Feb 28, 2024
@dummdidumm dummdidumm self-assigned this Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants