Skip to content

Conversation

@davepagurek
Copy link
Collaborator

@davepagurek davepagurek commented May 10, 2025

Some of our signatures now support rest types, e.g. createVector. We currently do not display or type check this correctly. I've made a PR here to support type checking processing/p5.js#7803, and this adds the capability to display them in the reference.

It currently looks like this, using @GregStanton's idea borrowing from MDN the x1, x2, ..., xn syntax.
image

The Number: type is a little awkward here, but probably fine for now, and better than what we currently have.

For reference, how some other things display variadic arguments:

JavaScript

If we want the syntax section to reflect how one would write this in your own function, it would be:

createVector(...components)

...and also we'd document components as an array.

MDN

image

w3schools

image

Three.js

image

Lodash

image

Immutable.js

image

Oracle Java docs

image

@GregStanton
Copy link

This is fantastic @davepagurek! I love the list of documentation practices across the JS ecosystem and beyond :)

@davepagurek davepagurek merged commit c30d49e into 2.0 May 13, 2025
4 checks passed
@davepagurek davepagurek deleted the rest-types branch May 13, 2025 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants