htmx icon indicating copy to clipboard operation
htmx copied to clipboard

Broken TypeScript types in 1.9.10

Open nwalters512 opened this issue 2 years ago • 4 comments

There are two issues with the TypeScript types that prevent tsc from typechecking a project that uses HTMX:

  • The syntax at the following line is invalid (the ? should come before the :: https://github.com/bigskysoftware/htmx/blob/145627a5792520b10f35e86eea23ce5c388e0fb0/src/htmx.d.ts#L432
  • The type referenced on the following line (HtmxTriggerSpecification) does not exist: https://github.com/bigskysoftware/htmx/blob/145627a5792520b10f35e86eea23ce5c388e0fb0/src/htmx.d.ts#L438

The first is trivial to fix, but I'm not sure what the type for HtmxTriggerSpecification is supposed to be. If someone can point me in the right direction, I can open a PR.

It'd be great to have CI check these types to prevent future regressions!

nwalters512 avatar Jan 02 '24 18:01 nwalters512

Looking at this recent PR: #2107

Hey all, we're about to do a pretty significant refactor and unfortunately now isn't the right time to introduce this. The htmx typing story is at the moment incomplete—if you want to update the API types you're more than welcome to.

and

Haha the guidance is, for the moment, please hold off on TS changes.

EDIT: unless they're to the type declarations in the API interface.

Given that's the current stance, I question whether the triggerSpecsCache property should have been added (which was done as part of #2094).

scrhartley avatar Jan 02 '24 23:01 scrhartley

I imagine they shouldn't have been added. What's the best course of action here: remove triggerSpecsCache and fix the syntax error in ignoreTitle?

nwalters512 avatar Jan 30 '24 19:01 nwalters512

I opened https://github.com/bigskysoftware/htmx/pull/2261 to fix this.

nwalters512 avatar Jan 30 '24 20:01 nwalters512

Hey @nwalters512 , would you be willing to give a shot to htmx 2 on the v2.0v2.0 branch, on which we made some work on types? Precisely, we added JSDoc everywhere in the lib + now generate the typescript type declarations file instead of manually maintaining it. I would be very happy to have some feedback of actually-typescript-users on this, as I have myself no real idea how this is supposed to be used 😆 ⚠️ please note htmx 2 is in alpha at this moment!

Telroshan avatar Feb 25 '24 20:02 Telroshan