From 4574b7f03ccc85c4bebdbfd9475788456086704f Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 8 Aug 2024 12:27:40 -0400
Subject: many changes to add typing in place of 'any's etc

---
 src/client/util/InteractionUtils.tsx | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

(limited to 'src/client/util/InteractionUtils.tsx')

diff --git a/src/client/util/InteractionUtils.tsx b/src/client/util/InteractionUtils.tsx
index a07550e09..f3ede596d 100644
--- a/src/client/util/InteractionUtils.tsx
+++ b/src/client/util/InteractionUtils.tsx
@@ -1,8 +1,10 @@
+import { Property } from 'csstype';
 import * as React from 'react';
 import { Utils } from '../../Utils';
 import { Gestures } from '../../pen-gestures/GestureTypes';
 import './InteractionUtils.scss';
 
+// eslint-disable-next-line @typescript-eslint/no-namespace
 export namespace InteractionUtils {
     export const MOUSETYPE = 'mouse';
     export const TOUCHTYPE = 'touch';
@@ -11,7 +13,7 @@ export namespace InteractionUtils {
 
     const ERASER_BUTTON = 5;
 
-    export function makePolygon(shape: string, points: { X: number; Y: number }[]) {
+    export function makePolygon(shape: Gestures, points: { X: number; Y: number }[]) {
         // if arrow/line/circle, the two end points should be the starting and the ending point
         let left = points[0].X;
         let top = points[0].Y;
@@ -19,7 +21,7 @@ export namespace InteractionUtils {
         let bottom = points[1].Y;
         if (points.length > 1 && points[points.length - 1].X === points[0].X && points[points.length - 1].Y + 1 === points[0].Y) {
             // pointer is up (first and last points are the same)
-            if (![Gestures.Arrow, Gestures.Line, Gestures.Circle].includes(shape as any as Gestures)) {
+            if (![Gestures.Arrow, Gestures.Line, Gestures.Circle].includes(shape)) {
                 // otherwise take max and min
                 const xs = points.map(p => p.X);
                 const ys = points.map(p => p.Y);
@@ -98,8 +100,8 @@ export namespace InteractionUtils {
         color: string,
         width: number,
         strokeWidth: number,
-        lineJoin: string,
-        strokeLineCap: string,
+        lineJoin: Property.StrokeLinejoin,
+        strokeLineCap: Property.StrokeLinecap,
         bezier: string,
         fill: string,
         arrowStart: string,
@@ -108,8 +110,8 @@ export namespace InteractionUtils {
         dash: string | undefined,
         scalexIn: number,
         scaleyIn: number,
-        shape: string,
-        pevents: string,
+        shape: Gestures,
+        pevents: Property.PointerEvents,
         opacity: number,
         nodefs: boolean,
         downHdlr?: (e: React.PointerEvent) => void,
@@ -154,7 +156,7 @@ export namespace InteractionUtils {
                             <marker id={`arrowStart${defGuid}`} markerUnits="userSpaceOnUse" orient="auto" overflow="visible" refX={markerStrokeWidth * (arrowLengthFactor - arrowNotchFactor)} refY={0} markerWidth="10" markerHeight="7">
                                 <polygon
                                     style={{ stroke: color }}
-                                    strokeLinejoin={lineJoin as any}
+                                    strokeLinejoin={lineJoin as 'inherit' | 'round' | 'bevel' | 'miter'}
                                     strokeWidth={(markerStrokeWidth * 2) / 3}
                                     points={`${arrowLengthFactor * markerStrokeWidth} ${-markerStrokeWidth * arrowWidthFactor}, ${markerStrokeWidth * (arrowLengthFactor - arrowNotchFactor)} 0, ${arrowLengthFactor * markerStrokeWidth} ${
                                         markerStrokeWidth * arrowWidthFactor
@@ -166,7 +168,7 @@ export namespace InteractionUtils {
                             <marker id={`arrowEnd${defGuid}`} markerUnits="userSpaceOnUse" orient="auto" overflow="visible" refX={markerStrokeWidth * arrowNotchFactor} refY={0} markerWidth="10" markerHeight="7">
                                 <polygon
                                     style={{ stroke: color }}
-                                    strokeLinejoin={lineJoin as any}
+                                    strokeLinejoin={lineJoin as 'inherit' | 'miter' | 'round' | 'bevel'}
                                     strokeWidth={(markerStrokeWidth * 2) / 3}
                                     points={`0 ${-markerStrokeWidth * arrowWidthFactor}, ${markerStrokeWidth * arrowNotchFactor} 0, 0 ${markerStrokeWidth * arrowWidthFactor}, ${arrowLengthFactor * markerStrokeWidth} 0`}
                                 />
@@ -184,10 +186,10 @@ export namespace InteractionUtils {
                         filter: mask ? `url(#mask${defGuid})` : undefined,
                         opacity: 1.0,
                         // opacity: strokeWidth !== width ? 0.5 : undefined,
-                        pointerEvents: (pevents as any) === 'all' ? 'visiblepainted' : (pevents as any),
+                        pointerEvents: pevents === 'all' ? 'visiblePainted' : pevents,
                         stroke: color ?? 'rgb(0, 0, 0)',
                         strokeWidth,
-                        strokeLinecap: strokeLineCap as any,
+                        strokeLinecap: strokeLineCap,
                         strokeDasharray: dashArray,
                         transition: 'inherit',
                     }}
-- 
cgit v1.2.3-70-g09d2

