-
Notifications
You must be signed in to change notification settings - Fork 30
Convert remainder of library to TypeScript, Vite build, include type checking in CI #158
Convert remainder of library to TypeScript, Vite build, include type checking in CI #158
Conversation
I've marked this as draft pending merge of enketo/enketo#1137 and resolution of questions brought up in PR description.
This feels similar to EE and I think it would be an improvement to stop publishing those docs (similar to enketo/enketo#988). I'm in favor of the "null option". I think Core is the one component that does benefit from web-available JS API docs (as opposed to just in source). But we can decide what to do about that when we get there. I'm in favor of removing all things around doc publishing as part of this PR.
This alarmed me so I asked @eyelidlessness about it. Since a lot of the comments have incomplete or no types, the resulting docs end up being misleading or incomplete (e.g. type |
e8c5f90
to
08d5a4e
Compare
(I've learned my lesson from enketo#157, hopefully this will make it easier to review!)
Adds separate test-specific config for Vitest's globals
While adding types, I found some of these names fairly hard to understand. There's some bikeshedding here in terms of name length, of course, but I do think this helps make more of the code self-documenting
Again there may be some subjective choices (i.e. `ignoreMatch` and the minor regex changes to avoid passing unnecessary capture groups to replacer functions), but I think it makes the intent more clear
Per discussion, the README is sufficient and more useful documentation
08d5a4e
to
60dd8e4
Compare
- Fixes Vite build - Fixes `tsc` - Adds types for config/build.shared.js - Uses shared build config where possible - Adds typedef emit - Fixes reference to `config.json` which works locally but failed in CI
4e332d8
to
6ad645b
Compare
This also removes backwards compatibility considerations for those
It all looks good to me. I've verified that what's documented in the README still works. I'm going to let this simmer and plan to do another sanity check and merge on Monday if there are no other comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Github action needs to be updated to not build docs. I think we'll use the Github console to disable the Github.io site after that, right?
Is "Debugging test watch mode in VSCode" still up to date?
* @param sample - A text sample. | ||
* @return either 'rtl' or the default 'ltr'. | ||
* TODO: According to the prior JSDoc, the default is supposed to be | ||
* {@link Directionality.LTR}, but the logic suggests the opposite. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed this is weird.
Just kidding, I was looking for it in the latest commits but it's done at 874b4b8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went through commit by commit quickly trying to verify functional parity.
Makes progress towards:
libxslt
dependencyThis PR:
express
adapter as node dev serverOriginal discussion of what to do about published docs
Branched from enketo/enketo-express#157. Here is a full diff, but it's probably more useful to view it after most of the file renames. I don't think there's much that needs much explanation, nor much that could be controversial here besides Typescript itself, and...
... docs
Aside from the obvious change, there's one thing I've left for discussion, which I honestly did not anticipate being such a blocker in this process: docs. I've currently commented out the
build-docs
command in CI, because it just plain doesn't work right now.The
jsdoc
library can be made to "work" with TypeScript, for values of "work" ranging from "very poorly" (i.e. none of the types are included in API documentation) to "I can invest more time for unknown quality" (i.e. there is tooling which can convert the types back to JSDoc, but I don't know how well it works and I'd need to wrap it in a customjsdoc
plugin). Searching forjsdoc
solutions is also very... not great, because the library shares its name with JSDoc, the comment documentation spec we've been using until now, and the library is even maintained in a monorepo alongside that spec and other related stuff.I believe the most popular ~equivalent for TypeScript is
typedoc
. I took some more time to look into it, and while it's an impressive project, it comes with some caveats:The ecosystem seems to be both stagnant and fractured. I discovered this because I didn't especially like the default theme's low contrast, and wanted to find one more like the one we currently use. There are viable options, but many of them have been adapted to breaking changes introduced over a year ago. Thankfully, it's easy to add custom styles and tweak it to increase contrast and even be more like the existing styles, however.
The breaking changes in question are technically semver-valid... with 0.x versioning. While Transformer's docgen requirements are relatively light (and I'll add below that they maybe should be lighter still), I'm concerned that this could be an issue for eventually converting other Enketo projects.
Options
The null option: For Transformer alone, I think there's a much simpler no-tooling solution: the intended public interface is (I believe) just
transform
andescapeURLPath
(which is presently only exported as an implementation detail for Express). They're documented directly with types and JSDoc, andtransform
is more thoroughly documented inREADME.md
. The currently generated docs expose a great deal of package-private stuff that really isn't valuable to users, and some of it quite obviously wrong. I always like a "do nothing" choice in discussions like this, even if I think it's completely unviable. In this case, I think it's the best option for Transformer... but maybe not for preparing for converting anything else in Enketo to TypeScript.Make
jsdoc
happen: As discussed above, I don't know how much work would be involved nor how fruitful it would be. It would also continue producing not very valuable docs.Make
typedoc
happen: This is probably more viable. I made good progress, the biggest open question to me is how well it'll support the documentation needs of other projects. This feels like it would warrant a spike, and probably a separate PR.Some other tooling: 🤷♂️
Minimally greater than null:
This does seem viable too. It's just a big change.