Skip to content

Commit 7e37280

Browse files
crisbetojelbourn
authored andcommitted
fix(drag-drop): improved type safety for drag events (#12740)
Adds generic params to all the drag events, now that `CdkDrag` is also generic.
1 parent 7d140a2 commit 7e37280

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/cdk-experimental/drag-drop/drag-events.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,34 @@ import {CdkDrag} from './drag';
1010
import {CdkDropContainer} from './drop-container';
1111

1212
/** Event emitted when the user starts dragging a draggable. */
13-
export interface CdkDragStart {
13+
export interface CdkDragStart<T = any> {
1414
/** Draggable that emitted the event. */
15-
source: CdkDrag;
15+
source: CdkDrag<T>;
1616
}
1717

18-
1918
/** Event emitted when the user stops dragging a draggable. */
20-
export interface CdkDragEnd {
19+
export interface CdkDragEnd<T = any> {
2120
/** Draggable that emitted the event. */
22-
source: CdkDrag;
21+
source: CdkDrag<T>;
2322
}
2423

2524
/** Event emitted when the user moves an item into a new drop container. */
26-
export interface CdkDragEnter<T> {
25+
export interface CdkDragEnter<T = any, I = T> {
2726
/** Container into which the user has moved the item. */
2827
container: CdkDropContainer<T>;
2928
/** Item that was removed from the container. */
30-
item: CdkDrag;
29+
item: CdkDrag<I>;
3130
}
3231

3332
/**
3433
* Event emitted when the user removes an item from a
3534
* drop container by moving it into another one.
3635
*/
37-
export interface CdkDragExit<T> {
36+
export interface CdkDragExit<T = any, I = T> {
3837
/** Container from which the user has a removed an item. */
3938
container: CdkDropContainer<T>;
4039
/** Item that was removed from the container. */
41-
item: CdkDrag;
40+
item: CdkDrag<I>;
4241
}
4342

4443

0 commit comments

Comments
 (0)