Skip to content

Commit 333fb6b

Browse files
committed
refactor(util.ts): adds return types to functions
1 parent 9d8fca1 commit 333fb6b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/util.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { AllMethodNames, ItemInterface, ReactSortableProps } from "./types";
77
* Removes the `node` from the DOM
88
* @param node
99
*/
10-
export function removeNode(node: HTMLElement) {
10+
export function removeNode(node: HTMLElement):void {
1111
if (node.parentElement !== null) node.parentElement.removeChild(node);
1212
}
1313

@@ -21,7 +21,7 @@ export function insertNodeAt(
2121
parent: HTMLElement,
2222
newChild: HTMLElement,
2323
index: number
24-
) {
24+
):void {
2525
const refChild = parent.children[index] || null;
2626
parent.insertBefore(newChild, refChild);
2727
}
@@ -32,16 +32,16 @@ export function insertNodeAt(
3232
// @todo - do I need parenElement?
3333
export function handleDOMChanges<T extends ItemInterface>(
3434
customs: Normalized<T>[]
35-
) {
35+
):void {
3636
removeNodes(customs);
3737
insertNodes(customs);
3838
}
3939

40-
export function removeNodes<T extends ItemInterface>(customs: Normalized<T>[]) {
40+
export function removeNodes<T extends ItemInterface>(customs: Normalized<T>[]):void {
4141
customs.forEach((curr) => removeNode(curr.element));
4242
}
4343

44-
export function insertNodes<T extends ItemInterface>(customs: Normalized<T>[]) {
44+
export function insertNodes<T extends ItemInterface>(customs: Normalized<T>[]) :void{
4545
customs.forEach((curr) => {
4646
insertNodeAt(curr.parentElement, curr.element, curr.oldIndex);
4747
});
@@ -50,7 +50,7 @@ export function insertNodes<T extends ItemInterface>(customs: Normalized<T>[]) {
5050
export function createCustoms<T extends ItemInterface>(
5151
evt: MultiDragEvent,
5252
list: T[]
53-
) {
53+
):Normalized<T>[] {
5454
const mode = getMode(evt);
5555
const parentElement = { parentElement: evt.from };
5656
let custom = [];
@@ -128,7 +128,7 @@ export function handleStateAdd<T extends ItemInterface>(
128128
return newList;
129129
}
130130

131-
export function getMode(evt: MultiDragEvent) {
131+
export function getMode(evt: MultiDragEvent):'multidrag'|"swap"|"normal" {
132132
if (evt.oldIndicies && evt.oldIndicies.length > 0) return "multidrag";
133133
if (evt.swapItem) return "swap";
134134
return "normal";

0 commit comments

Comments
 (0)