Typescript type declarations
marcw opened this issue · comments
Marc Weistroff commented
Hello and thanks for the library.
This is a bit of a niche feature request: It would be absolutely awesome to provide type declaration for Typescript users.
Many thanks
Peter Shershov commented
Not niche at all :)
Zeno Zeng commented
Hi, I just rewrote the entire lib in TypeScript and released the new version v1.5.1. If you have time, you can try it out. Additionally, I also added a TypeScript + Vite example here: https://github.com/zenozeng/p5.js-svg/blob/main/examples/vite/src/main.ts
Peter Shershov commented
@zenozeng thanks man! I'll test it soon
Peter Shershov commented
@zenozeng Hey, I just tried the Vite example and I'm getting the following error when trying to run it:
Here's my code (same as the example):
import "./style.css";
import p5 from "p5";
import init, { p5SVG } from "p5.js-svg";
init(p5);
const sketch = (p: p5SVG) => {
p.setup = () => {
p.createCanvas(400, 400, p.SVG)
};
p.draw = () => {
p.background(220);
p.ellipse(50, 50, 80, 80);
};
};
new p5(sketch, document.body);