Skip to content

Commit

Permalink
Fix generics for manager passed to Entity
Browse files Browse the repository at this point in the history
  • Loading branch information
clauderic committed Sep 12, 2024
1 parent bfc8ab2 commit e70b29a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/fix-generics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@dnd-kit/abstract': patch
'@dnd-kit/dom': patch
---

Make sure the generic for `DragDropManager` is passed through to `Entity` so that the `manager` reference on classes extending `Entity` is strongly typed.
2 changes: 1 addition & 1 deletion packages/abstract/src/core/entities/draggable/draggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type DraggableStatus = 'idle' | 'dragging' | 'dropping';
export class Draggable<
T extends Data = Data,
U extends DragDropManager<any, any> = DragDropManager<any, any>,
> extends Entity<T> {
> extends Entity<T, U> {
constructor(
{modifiers, type, sensors, ...input}: Input<T>,
manager: U | undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/abstract/src/core/entities/droppable/droppable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface Input<T extends Data = Data> extends EntityInput<T> {
export class Droppable<
T extends Data = Data,
U extends DragDropManager<any, any> = DragDropManager<any, any>,
> extends Entity<T> {
> extends Entity<T, U> {
constructor(
{accept, collisionDetector, collisionPriority, type, ...input}: Input<T>,
manager: U | undefined
Expand Down
5 changes: 4 additions & 1 deletion packages/dom/src/core/entities/draggable/draggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export interface Input<T extends Data = Data> extends DraggableInput<T> {
modifiers?: Modifiers<DragDropManager>;
}

export class Draggable<T extends Data = Data> extends AbstractDraggable<T> {
export class Draggable<T extends Data = Data> extends AbstractDraggable<
T,
DragDropManager
> {
constructor(
{
element,
Expand Down
5 changes: 4 additions & 1 deletion packages/dom/src/core/entities/droppable/droppable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export interface Input<T extends Data = Data>
element?: Element;
}

export class Droppable<T extends Data = Data> extends AbstractDroppable<T> {
export class Droppable<T extends Data = Data> extends AbstractDroppable<
T,
DragDropManager
> {
constructor(
{element, effects = () => [], ...input}: Input<T>,
manager: DragDropManager | undefined
Expand Down

0 comments on commit e70b29a

Please sign in to comment.