I am building an application in Typescript which relies on the P5.js library.
P5.js puts a lot of functions on the global namespace so they can be called in your webapp by just saying things like draw(), and ellipse(x, y, w, l) etc...
I am working in Webstorm and I want Webstorm to be able to perform its static analysis for me, so I have been adding the function names of P5.js to a p5.d.ts file (there is no p5.js Typescript definition file published yet), like:
declare var setup: () => void; declare var draw: () => void; declare var background: (color: number) => void; declare var stroke: (r: number, g: number, b: number) => void; ... However this is not ideal.
#1: These functions actually do return something - a P5 Object - which contains all these methods, though it's usually not used.
#2: I am still calling these methods throughout my application without any prefix or anything. This makes it a bit ambiguous as to where these functions are actually from.
There are more issues as well...
Can anyone offer some pointers on how to go about creating a .d.ts for a library like P5.js?