Dev overhaul for internal type checking - not for merging #41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
cdnorlocal, 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:
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:
.vscode/tasks.jsonnpm run type-checkwhich 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 donpm run type-check --watchas 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.