From ad0c15a3ac7322ec89c3bae2b1a3a4b982f00cd7 Mon Sep 17 00:00:00 2001 From: kyechan99 Date: Fri, 19 Jul 2024 23:47:56 +0900 Subject: [PATCH] fix: specify return type Path.getPoint* methods --- src/shapes/Path.ts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/shapes/Path.ts b/src/shapes/Path.ts index e91f5400..67a905e2 100644 --- a/src/shapes/Path.ts +++ b/src/shapes/Path.ts @@ -235,8 +235,8 @@ export class Path extends Shape { return pathLength; } - static getPointAtLengthOfDataArray(length: number, dataArray) { - var point, + static getPointAtLengthOfDataArray(length: number, dataArray: PathSegment[]) { + var points: number[], i = 0, ii = dataArray.length; @@ -250,18 +250,18 @@ export class Path extends Shape { } if (i === ii) { - point = dataArray[i - 1].points.slice(-2); + points = dataArray[i - 1].points.slice(-2); return { - x: point[0], - y: point[1], + x: points[0], + y: points[1], }; } if (length < 0.01) { - point = dataArray[i].points.slice(0, 2); + points = dataArray[i].points.slice(0, 2); return { - x: point[0], - y: point[1], + x: points[0], + y: points[1], }; } @@ -319,7 +319,15 @@ export class Path extends Shape { return null; } - static getPointOnLine(dist, P1x, P1y, P2x, P2y, fromX?, fromY?) { + static getPointOnLine( + dist: number, + P1x: number, + P1y: number, + P2x: number, + P2y: number, + fromX?: number, + fromY?: number + ) { fromX = fromX ?? P1x; fromY = fromY ?? P1y;