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

Data typing #37

Open
Scimonster opened this issue Apr 7, 2024 · 1 comment
Open

Data typing #37

Scimonster opened this issue Apr 7, 2024 · 1 comment

Comments

@Scimonster
Copy link

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.

@quantrung
Copy link

Why is no one talking about this???

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

No branches or pull requests

2 participants