I'm trying to compile a p5.js program in advanced mode.
I understand I need to include externs for the p5.js functions I'm calling so the compiler does not rename them, and I'm doing this and it works fine.
I also understand I need to let the compiler know that the setup() and draw() functions (and anything else p5 calls) I'm defining are called from elsewhere, so must not be renamed and must not be deleted. I have read everything that I can find about this (including threads in this group) but I am apparently missing something.
Here's a trivial example (I know the p5 externs are not exactly complete, but they're sufficient for this example)
myp5.js:
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
square(5,5,100);
}
p5js.externs:
/**
* @param {number} x
* @param {number} y
* @return {undefined}
*/
function createCanvas(x,y) {}
/**
* @param {number|string} c
* @return {undefined}
*/
function background(c) {}
/**
* @param {number} x
* @param {number} y
* @param {number} size
* @return {undefined}
*/
function square(x,y,size) {}
My question is what is the syntax for the externs for the functions I'm defining (setup and draw in this case) that I do not want renamed, and do not want deleted? As far as I can tell it's something like
/**
* @return {undefined}
*/
function setup() {}
/**
* @return {undefined}
*/
function draw() {}
but this says only not to rename these functions (and, with these externs I can see the functions are indeed not renamed if I include calls to them). How to I tell the compiler I also want them not to be deleted even though it looks like they're not called?