Skip to content

Conversation

@nbogie
Copy link
Collaborator

@nbogie nbogie commented Dec 16, 2025

Hi! I'm not suggesting you merge this, just in case you're interested. If you don't have the time or energy to consider it at the moment, that's understandable, too!

I overhauled the create-p5 code to make it internally consistent - no functions being called with the wrong number or type of arguments - to get it to generally type-check, and to slightly improve some of the types of the values being thrown around.

e.g. deliveryMode is exactly one of cdn or local , rather than a string. same for language, same for p5Mode. And all modules share those type definitions so if it changes, it changes everywhere (Admittedly, they're shared somewhat clunkily via jsdoc typedef imports).

Before, it was impossible to switch on checkJs on the project or for a single module, because there was a LOT wrong. This experimentally would provide a stable basis from which you could go forward.

I also caught a couple of very minor bugs while working through it, which I'll add as issues.

Why not suggesting merge

Although it was quite a bit of work, i'm not suggesting merging yet, because:

  • I haven't tested comprehensively enough yet to make sure I haven't broken anything. Mostly I didn't change the code as much as the jsdocs, but I had to change a couple of things around, mostly in the name of error-checking.
  • I also haven't fixed all the type errors in the tests yet - they're ignored in tsconfig.
  • I didn't update any LLM instructions - it was enough work just getting the types checking.
  • You might also hate the look of the code with all the jsdoc annotations scattered around.
  • Also you might not like the idea of having typescript be a dev dependency. That worry would be misplaced, I think:

Why is typescript a dev dependency? This is a JS project

So it's NOT really dev dependency - in the sense that you can code on this project as much as you like without installing typescript. But i've listed it as one in package.json just so that you can get type-checking across ALL files, not just across the ones that are open - a vscode limitation, I think. You can do this in one of two ways:

  • inside vscode with ctrl-shift-b - a full report of errors will come into the problems window. I've set this up using .vscode/tasks.json
  • Optionally from the command-line with npm run type-check which means you can add it as a CI (google actions) step, and I guess AI agents also have more chance of being able to consider it (I don't know if your claude setup is already running linting, unit tests against its own suggestions?). You can also do npm run type-check --watch as you're coding, to quickly be notified when you break something.

It's important to note there's still no actual build step (it's still a pure js project, I haven't written any files in typescript, nothing needs to be transpiled into js), I'm just using typescript to get more info about bugs in the JS code.

…self

Includes a vs-code task (ctrl-shift-b to trigger it) which type-checks all files and populates problems window

tsconfig excludes templates from type-checking for now, this tooling is is intended to check the heart of the check-js tool itself for inconsistencies.
@SableRaf SableRaf marked this pull request as draft December 20, 2025 14:57
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