Skip to content

Error when binding to a prop that is also an exported identifier #14805

@kran6a

Description

@kran6a

Describe the bug

If you have a component like this you cannot bind the prop open

<script lang="ts">
    let {open: is_open = $bindable(false)}: Props = $props();
    export const open = ()=>{
        console.log("open export called");
    }
</script>

<div>AAA</div>

We should be able to bind to the open prop even if we cannot bind to the open export

Reproduction

Remove the comment to see the error

https://svelte.dev/playground/untitled?version=5.15.0#H4sIAAAAAAAACo1R0WrDMAz8FU0MmkLSvKdJINsP7H0ew2nUzODKJnZLR8i_D6XNWMsGw2AknXTWnUdkfSAs8MlwZ7gHzR3Q2bshQnvsMcW9sRSweB0xfnrplAKmy1zj_SacyEaptTrQb_Wd40gcAxZYht1gfASrua8UxqCwVgxgDvObzx_GdrAf3AFWm3zOrjSrrWIVLUVwnhgqeAxRR0r22gZabxWX-YW6Vqy4vBBJazXKPeW14vIhy-AKtYa74gaHLKsxxUjniEUcjjSlf4j-udet7DvkH8IBRNO8QwEmvC_qZD_d2kXgVMDL4HwQyEuQiGYZv_7WznH49iZZV_UofskRxFnaWNcnCueOZUZbS53ChWq6d7Ezp7ppmjKX4Nabt-kLXnLCnjwCAAA=

Logs

bind_invalid_export Component Child.svelte has an export named `open` that a consumer component is trying to access using `bind:open`, which is disallowed. Instead, use `bind:this` (e.g. `<Child bind:this={component} />`) and then access the property on the bound component instance (e.g. `component.open`) https://svelte.dev/e/bind_invalid_export

System Info

Does not matter

Severity

annoyance

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