Open cormacrelf opened 5 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stalebot pls
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Stalebot is the worst for actual issues. I get a reminder nobody has paid any attention to the issue, but I'm not the one that needs reminding.
Is your feature request related to a problem? Please describe. The typings for the
createTouchBackend
function erase theTouchBackendOptions
. It is re-typed as aBackendFactory
, which means itsoptions?
argument is simplyany
.https://github.com/react-dnd/react-dnd/blob/15b5c0da0c66db594b90814d007d9a2e6caaea95/packages/core/touch-backend/src/index.ts#L5-L9
That means you don't get type checking when you supply the options. Not even if you create a backend like this:
Describe the solution you'd like
BackendFactory
could take an optional type parameter to describe the type of the options to be passed in. Then you wouldn't have to erase the type:This would not be a breaking change, as
BackendFactory
alone is still valid.Describe alternatives you've considered A less tidy solution would be to remove the re-typing, because createTouchBackend already conforms to the BackendFactory interface, but this wouldn't be a type-checked guarantee. And see below for more functionality it would miss.
Additional context The old TouchBackend was typed as
TouchBackend: (options: TouchBackendOptions) => BackendFactory;
, where that argument was basically curried. That enabled typing in the same spot, whereas now, the options type has to be carried around a bit in the type system so it can appear in the right place. Forreact-dnd
, the two places arecreateDragDropManager
andDndProvider
'soptions
property. The type could be carried across to the options property, such that it would have to match the backend property. E.g.:For
@angular-skyhook
, that's in theSkyhookDndModule.forRoot
function (I haven't updated this yet).