Skip to content

Conflict between const and $bindable #15754

Closed as not planned
Closed as not planned
@AsaMitakaIT

Description

@AsaMitakaIT

This comes down to stylistic preference. I personally for example want to use const for components that only have readonly props. Or I prefer to use const for $derived because for me it better communicates that this is a readonly value, not necessarily that the value itself never changes.

We shouldn't be in the business of dictating these preferences, therefore closing.

Originally posted by @dummdidumm in #12121

<script lang="ts">
    let { options, selected = $bindable() }: { options: string[], selected: number } = $props();
</script>

In this scenario, I’d like to define both const options and let selected simultaneously, but I can’t invoke $props twice. I suppose there’s currently no solution for this?

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