From c80b905bcbaf2d72bcedebddc9d2c4e3bcac8927 Mon Sep 17 00:00:00 2001 From: Qiushi Pan <17402261+qqpann@users.noreply.github.com> Date: Sun, 19 Oct 2025 21:28:13 +0900 Subject: [PATCH] fix: type error --- src/index.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 2958bae4..dd74914b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,7 +36,7 @@ export { Vector2, }; -const defaultProps: ConfigurationOptions = { +const defaultProps = { delta: 10, preventScrollOnSwipe: false, rotationAngle: 0, @@ -44,7 +44,7 @@ const defaultProps: ConfigurationOptions = { trackTouch: true, swipeDuration: Infinity, touchEventOptions: { passive: true }, -}; +} satisfies ConfigurationOptions; const initialState: SwipeableState = { first: true, initial: [0, 0], @@ -278,9 +278,13 @@ function getHandlers( ], [touchEnd, onEnd, baseOptions], ]; - tls.forEach(([e, h, o]) => el.addEventListener(e, h, o)); + tls.forEach(([e, h, o]) => { + el.addEventListener(e, h, o) + }); // return properly scoped cleanup method for removing listeners, options not required - cleanup = () => tls.forEach(([e, h]) => el.removeEventListener(e, h)); + cleanup = () => tls.forEach(([e, h]) => { + el.removeEventListener(e, h) + }); } return cleanup; }; @@ -395,11 +399,12 @@ export function useSwipeable(options: SwipeableProps): SwipeableHandlers { const [handlers, attachTouch] = React.useMemo( () => getHandlers( - (stateSetter) => - (transientState.current = stateSetter( + (stateSetter) => { + transientState.current = stateSetter( transientState.current, transientProps.current - )), + ); + }, { trackMouse } ), [trackMouse]