Skip to content

Conversation

davepagurek
Copy link
Contributor

@davepagurek davepagurek commented Sep 26, 2025

Resolves #7862
Resolves #7938

This builds off of #7863 and refactors how typescript type generation is done, and adds integration tests to make sure sketches that use the types all work correctly. We can add new .ts files into the test/types folder to verify that they work correctly.

  • Rather than a duplicate implementation, I merged a lot of code with the reference generation. Both use the same data processor to read the Documentation.js output now, and each passes in a separate strategy for walking type info, as typescript types look different than the syntax we use in the reference.
  • Rather than trying to preserve 1:1 relationship between source files and .d.ts files, this generates a single p5.d.ts (and a global.d.ts.) We can split this up further in the future if we really need, but this makes class generation a lot less brittle.
  • I caught and fixed a number of small bugs in Documentation.js resulting from the placement of our block comments or copy and paste errors.

TODO:

  • Add back in patches for generic types
  • Better types for callback function parameters Update: probably going to leave this for now since it'll affect the reference generation too. Future PR maybe!

PR Checklist

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.

2 participants