So I have this node_modules/@types file with definitions I need. However, I can't seem to import it into my js file.
I've done npm install @types/p5
and added it to my tsconfig.json like:
"types": [
"node",
"p5"
],
but name is still not found.
My code is essentially this:
import * as p5 from 'p5';
//imports p5.js
export class Box {
...
show(p5) {
p5.rectMode(CENTER);
{
...
}
CENTER needs to be defined but it isn't.
CENTER
is inside your p5
instance, because you've imported all from @types/p5
as p5
:
const p = new p5(...); // specify arguments for p5
show(p) {
p.rectMode(p.CENTER); // p.CENTER returns 'center'
}