Skip to content

Commit

Permalink
Allow type of jCanvas plugin props to be inferred
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb531 committed May 30, 2024
1 parent 411cb8b commit 5ea75c3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/jcanvas-crescents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function getIntersection(
return [xi, yi];
}

$.jCanvas.extend<{ eclipse: number }>({
$.jCanvas.extend({
name: "drawCrescent",
type: "crescent",
props: {
Expand Down
2 changes: 1 addition & 1 deletion src/jcanvas-donuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import $ from "jquery";

const PI = Math.PI;

$.jCanvas.extend<{ holeSize: number }>({
$.jCanvas.extend({
name: "drawDonut",
type: "donut",
props: {
Expand Down
2 changes: 1 addition & 1 deletion src/jcanvas-hearts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import $ from "jquery";

const PI = Math.PI;

$.jCanvas.extend<{ size: number }>({
$.jCanvas.extend({
name: "drawHeart",
type: "heart",
props: {
Expand Down
4 changes: 2 additions & 2 deletions src/jcanvas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ declare module "jcanvas/dist/esm/jcanvas-donuts.min.js";
declare module "jcanvas/dist/esm/jcanvas-hearts.min.js";
declare module "jcanvas/dist/esm/jcanvas-handles.min.js";

interface JCanvasPluginParams<TProps> {
interface JCanvasPluginParams<TProps extends object> {
name: string;
props?: Record<string, any>;
props?: TProps;
type?: string;
fn: (
this: HTMLCanvasElement,
Expand Down

0 comments on commit 5ea75c3

Please sign in to comment.