Convert htmx to TypeScript 😍
See original GitHub issueTypeScript would bring lots of DX benefits to the htmx source code. Besides the obvious strict type checking, we would be able to write code using the latest and greatest ECMAScript 2021, but continue compiling to ES5 (to support IE11), or any version of ECMAScript really, with a single config setting.
{
"compilerOptions": {
"target": "ES5"
}
}
I’ve started a WIP branch in which I’ve converted htmx.js
to htmx.ts
, changing the minimum amount of code possible, and it is compiling with all tests passing.
@1cg in theory, we could merge this branch into the dev
branch before the next minor release, and start converting the source code incrementally.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:12
- Comments:32 (7 by maintainers)
Top Results From Across the Web
Refactoring a Static HTML Site Into Typescript, Part 1 of 2
There are two big pieces of work: Converting the content from static HTML to Typescript functions. Converting the navigation from href link to ......
Read more >Convert HTML Javascript to Angular TypeScript?!? : r/Angular2
Please make sure your browser load file app.js. You can add script direct to index.html file. if you don't want to bundle that...
Read more >How To Convert Html Website To React Js App (Simple Method)
How to convert an HTML website into a react js application and how to host it ... Get 82% discount 😍 from hostinger...
Read more >Parcel
Start with an HTML file. Add a <script> tag. Maybe some CSS. How about TypeScript? SASS? Images? No problem. Parcel works out of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think this may have already been settled, but I’ll just add this for posterity. Typescript is made for codebases EXACTLY like htmx. The compiler can be set to work with existing *.js files, and there’s even an option to include (almost) all of the Typescript annotations as backwards-compatible JSDoc comments.
A small band of Typescript fanatics (including me) have been sneaking JSDoc/Typescript comments into htmx and hyperscript for a while, now 😃 This gives us the benefits of using Typescript with little additional developer overhead. The comments are a little more clunky than pure Typescript, but it lets us get started while we work out the infrastructure.
Of course up to @1cg to decide if this switch is actually worthwhile, but will have to say no thanks because:
The ECMAScript spec will probably supersede TypeScript in the near future anyway. This has happened historically with other dead Javascript dialects (example: when classes were included in ES6).