Skip to content

Errors with Dropdown with custom slots and Typescript #1202

@Lucide

Description

@Lucide

I can't get the slotted Dropdown to work with Typescript:
image

<script lang="ts">
    import { Dropdown } from "carbon-components-svelte";
    let items = [
        { id: "0", text: "Slack" },
        { id: "1", text: "Email" },
        { id: "2", text: "Fax" },
    ];
</script>

<div>
    <Dropdown titleText="Contact" selectedId="0" {items} let:item let:index>
        <div>
            <strong>{item.text}</strong>
        </div>
        <div>
            id: {item.id} - index:
            {index}
        </div>
    </Dropdown>
</div>

<style lang="scss">
    :global(.bx--list-box__menu-item, .bx--list-box__menu-item__option) {
        height: auto;
    }
</style>

In the console I get this warning on every refresh: <Dropdown> received an unexpected slot "default".
The rendered output shows the Dropdown with the standard UI. Do I need to do something special to make it work with ts?

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