hello-pangea / dnd

💅 Beautiful and accessible drag and drop for lists with React. ⭐️ Star to support our work!
https://dnd.hellopangea.com
Other
2.5k stars 95 forks source link

Add Generics to `DropResult` type #817

Closed Mnigos closed 2 months ago

Mnigos commented 3 months ago

Description

Making DropResult a generic type to specify type of droppableId

Right now I have to assert the type.

  async function onDragEng({ source, destination, draggableId }: DropResult) {
    if (!destination) return

    if (destination.droppableId === source.droppableId) {
      reorderTasks(
        source.droppableId as BoardKey,
        source.index,
        destination.index
      )
    }
  }

I would like to specify type for droppableId in DropResult type argument

  async function onDragEng({ source, destination, draggableId }: DropResult<BoardKey>) {
    if (!destination) return

    if (destination.droppableId === source.droppableId) {
      reorderTasks(
        source.droppableId,
        source.index,
        destination.index
      )
    }
  }