-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix TypeScript types #2261
Fix TypeScript types #2261
Conversation
We're doing a big re-work for this for htmx 2.0! |
@alexpetros that's exciting! Is v2 going to be released shortly? The latest version of |
The beta should be out in a couple weeks. I'm not sure I agree that htmx is unusable in TypeScript projects, as there are a lot of ways to enable htmx in TS projects that don't require typed DOM attributes or APIs (with templates, for instance). Broadly speaking, htmx enables you to have minimal logic (and therefore minimal scripting) in the frontend, drastically diminishing the need for TypeScript's guarantees to extend past the backend. Many people use statically-typed backends with htmx happily. I'm sure it's a problem for whatever your rendering setup is, and I apologize for that. I know this response is sort of annoying, but I don't want anyone to find this comment and think it applies to TypeScript projects generally. |
Sorry, to be clear, I don't mean that it's unusable because of any lack of type declarations or such. I don't actually rely on any of that, and I don't have a "rendering setup" that necessitates any type information from HTMX at all. I love that HTMX lets me avoid a huge amount of scripting on the frontend, and of course I don't require type checking for scripts that don't exist. I have an
This isn't silenceable with a I would be equally happy if the fix to #2148 was to remove |
Currently version 1.19.10 is unusable for us as well, we had to manually pin the version to 1.19.9 for now. +1 for this PR as it seems to be the easiest way to resolve this. |
Much appreciated on the explanation, I had indeed misunderstood what you were saying. I do think we're going to need to do a 1.9.11, so I'll reopen this and we'll get it looked at. |
Description
This PR fixes the TypeScript types in
src/htmx.d.ts
. There were two separate issues:triggerSpecsCache
referenced aHtmxTriggerSpecification
type the doesn't existGiven the guidance in #2107 (comment), I opted to remove the types for
triggerSpecCache
entirely.Interestingly, there are other parts of the code (JSDoc comments) that reference
HtmxTriggerSpecification
:htmx/src/htmx.js
Line 1273 in 7f3d114
htmx/src/htmx.js
Line 1364 in 7f3d114
This leads me to believe that this type did exist at one point, but I couldn't immediately find it in the Git history. It seems like a type that should exist though!
Corresponding issue: #2148
Testing
I installed these types into my project and verified that
tsc
could now successfully parse the types.Checklist
master
for website changes,dev
for source changes)npm run test
) and verified that it succeeded