Skip to content

Commit

Permalink
Add Active and Over in hasSortableData type guard
Browse files Browse the repository at this point in the history
  • Loading branch information
clauderic committed Jun 9, 2022
1 parent 8fbbfd7 commit b6970e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/sortable-type-guard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@dnd-kit/sortable': patch
---

The `hasSortableData` type-guard that is exported by @dnd-kit/sortable has been updated to also accept the `Active` and `Over` interfaces so it can be used in events such as `onDragStart`, `onDragOver`, and `onDragEnd`.
12 changes: 10 additions & 2 deletions packages/sortable/src/types/type-guard.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import type {Data, DroppableContainer, DraggableNode} from '@dnd-kit/core';
import type {
Active,
Data,
DroppableContainer,
DraggableNode,
Over,
} from '@dnd-kit/core';

import type {SortableData} from './data';

export function hasSortableData<T extends DraggableNode | DroppableContainer>(
export function hasSortableData<
T extends Active | Over | DraggableNode | DroppableContainer
>(
entry: T | null | undefined
): entry is T & {data: {current: Data<SortableData>}} {
if (!entry) {
Expand Down

0 comments on commit b6970e7

Please sign in to comment.