I am using p5.js and was wondering if I could use Typescript to destructure all the the properties in the p5
object. Currently my code looks something like this:
const sketch2 = (p5: P5) => {
p5.setup = () => {
const canvas = p5.createCanvas(200, 200);
};
p5.draw = () => {
p5.fill(0);
p5.ellipse(100, 100, 80, 80);
};
};
I could do destructure every property but that could be quite tedious:
const sketch2 = (p5: P5) => {
let { setup, createCanvas, draw, fill, ellipse } = p5;
setup = () => {
const canvas = createCanvas(200, 200);
};
draw = () => {
fill(0);
ellipse(100, 100, 80, 80);
};
};
Could I use Typescript to destructure all the properties into the scope without naming them one by one?