Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSdoc in htmx.js + generated TypeScript definition #2336

Merged
merged 4 commits into from
Feb 21, 2024

Conversation

Telroshan
Copy link
Collaborator

Highlights

  • Added JSDoc basically everywhere
  • Used parent types whenever possible (i.e. Node instead of Element, Element instead of HTMLElement and so on)
  • Typescript types definition is now generated, using npm run type-declarations
  • Inlined public API's functions within the htmx object itself as tsc would otherwise generate invalid TypeScript code
  • I put all custom typedefs in the global scope so that tsc properly exports them, and at the bottom of the file as I thought it would be pretty annoying to have to scroll past 150~ lines of JSDoc to start reading the code
  • To avoid making too many changes to the code, I added a few // @ts-ignore in places where code is valid but tsc is too strict

Tests pass, also ran the tests in the extensions repo, all clear

Going further

If this is accepted, I would recommend going further with the following:

  • Call tsc in the npm t script to have the pipeline check the code is correctly typed before merging PRs
  • Make a custom JS script (called with node in the npm command along tsc) to copy the JSDoc descriptions and default values hints (as all JSDoc is lost along tsc's generation)

@Telroshan Telroshan added documentation Improvements or additions to documentation 2.0 labels Feb 19, 2024
@Telroshan Telroshan requested review from 1cg and alexpetros February 19, 2024 21:34
Copy link
Contributor

@1cg 1cg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@1cg 1cg merged commit f004978 into bigskysoftware:v2.0v2.0 Feb 21, 2024
1 check passed
@Telroshan Telroshan deleted the v2-jsdoc branch February 21, 2024 21:37
Telroshan added a commit that referenced this pull request Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.0 documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants