Skip to content

Commit

Permalink
Remove obsolete types
Browse files Browse the repository at this point in the history
- JCanvasLayerType
- JCanvasDrawingMethodName
  • Loading branch information
caleb531 committed Jun 13, 2024
1 parent 53631ff commit 000bcda
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 47 deletions.
42 changes: 1 addition & 41 deletions src/jcanvas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,6 @@ interface JCanvasPluginParams<TProps extends object> {
) => void;
}

type JCanvasLayerType =
| "arc"
| "bezier"
| "ellipse"
| "function"
| "image"
| "line"
| "path"
| "polygon"
| "slice"
| "quadratic"
| "rectangle"
| "text"
| "vector"
| "save"
| "restore"
| "rotate"
| "scale"
| "translate";

type JCanvasDrawingMethodName =
| "drawArc"
| "drawBezier"
| "drawEllipse"
| "draw"
| "drawImage"
| "drawLine"
| "drawPath"
| "drawPolygon"
| "drawSlice"
| "drawQuadratic"
| "drawRect"
| "drawText"
| "drawVector"
| "saveCanvas"
| "restoreCanvas"
| "rotateCanvas"
| "scaleCanvas"
| "translateCanvas";

type JCanvasMouseEventName =
| "click"
| "dblclick"
Expand Down Expand Up @@ -107,7 +67,7 @@ type JCanvasEventName =
| JCanvasImageEventName;

interface JCanvasMaps {
drawings: Record<string, JCanvasDrawingMethodName>;
drawings: Record<string, string>;
touchEvents: Partial<
Record<JCanvasInteractionEventName, JCanvasTouchEventName>
>;
Expand Down
8 changes: 2 additions & 6 deletions src/jcanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,7 @@ jCanvas.extend = function extend(plugin) {
};
// Add drawing type to drawing map
if (plugin.type) {
// We need to type-assert because the nature of $.jCanvas.extend
// implies that plugin.type is always a custom type which is not
// inherently part of JCanvasLayerType
maps.drawings[plugin.type as JCanvasLayerType] =
plugin.name as JCanvasDrawingMethodName;
maps.drawings[plugin.type] = plugin.name as string;
}
}
// @ts-expect-error TODO: fix this
Expand Down Expand Up @@ -1800,7 +1796,7 @@ function _addLayer(
} else if (params.method) {
params._method = $.fn[params.method];
} else if (params.type) {
params._method = $.fn[maps.drawings[params.type]];
params._method = $.fn[maps.drawings[params.type] as keyof JQuery];
}
}

Expand Down

0 comments on commit 000bcda

Please sign in to comment.