Skip to content

Data typing #37

@Scimonster

Description

@Scimonster

Hi, I'm using dnd-kit in a TypeScript project, and would like to strongly type the data property attached to Draggable objects.

I tried extending the interface, the way other libraries sometimes implement it, but it didn't work.

declare module '@dnd-kit/core/dist/store/types' {
    export interface Active {
        data: DataRef<MyDataType>;
    }
}

TypeScript gives an error Subsequent property declarations must have the same type. Property 'data' must be of type 'DataRef<AnyData>', but here has type 'DataRef<MyDataType>'.

It would be great if a future version could expose an API for either extending the interface, or at passing generics to the DnDContext component.

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