bigskysoftware / idiomorph

A DOM-merging algorithm
BSD 2-Clause "Simplified" License
631 stars 31 forks source link

Add JSDoc types and definitions #25

Open mkarajohn opened 6 months ago

mkarajohn commented 6 months ago

Added types to every function and config object, to the best of my ability.

One thing that surfaced from this process is that in some places functions expect arguments as Element, but the functions themselves may have been called in places where the arguments that are passed are of the broader Node type, not Element.

This could lead to bugs theoretically (big if true!); maybe it should get checked, I have placed some TODOs in there to get the reader's attention.

I also ran gen-modules > dist > uglify but I am not sure if I should have or if they are generated automatically.

1cg commented 6 months ago

Hi there. A couple of requests:

mkarajohn commented 6 months ago
  • Can you undo the changes to /dist? I'll generate those when we do the next release

Done

  • Do you know how to add a type checking task to the npm?

We will have to install typescript as a developer dependency. We won't be writing the code in TS nor we'll be shipping compiled code (...unless you want to write the source in TS and ship compiled code?); it's only needed in order to parse our JSDoc definitions and validate the code against them. If you are ok with that, we can add something like this

"typecheck": "tsc --allowJs --checkJs --noEmit --target ES5 src/*.js"

What do you say?

mkarajohn commented 6 months ago

For the record I am currently giving it a 2nd pass to clean up type errors that showed up with TS setup locally. I will be pushing a second commit during the day.

mkarajohn commented 6 months ago

Ok, the prevalent issue is that there are lots of cases such as .nextSibling, which return either Node or null values and these values are then passed to functions that expect Element arguments (e.g. the function isSoftMatch clearly expects Elements (or null) as arguments, since internally it tries to access properties that only exist in Elements and not Nodes, but the function itself is called with the return value of something.nextSibling, for example, which can either be Node or null)

Maybe properties such as .nextElementSibling should be used instead?

mkarajohn commented 6 months ago

Ok, a few comments:

I am here to help with whatever you decide to do

mkarajohn commented 6 months ago

@1cg

Not trying to be a nuisance, but is this still under consideration or should I stop thinking about it? 😂

It's fine if this won't go any further, I just need to have some kind of closure 😅

1cg commented 6 months ago

Hi dimiris no I am still interested in this. I have been mainly focused on htmx 2 though. Will try to get to this next week.

Sent from Proton Mail for iOS

On Fri, Dec 29, 2023 at 8:59 PM, Dimitris Karagiannis @.***(mailto:On Fri, Dec 29, 2023 at 8:59 PM, Dimitris Karagiannis < wrote:

@.***(https://github.com/1cg)

Not trying to be a nuisance, but is this still under consideration or should I stop thinking about it? 😂

It's fine if this won't go any further, I just need to have some kind of closure 😅

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

1cg commented 6 months ago

Still interested in this, but htmx 2.0 is taking up all my time. I promise I will get to it by the end of the month though.

mkarajohn commented 6 months ago

No worries no worries, since you said you have not abandoned it the first time around that was all I wanted to know; don't feel like you have to explain yourself, I realize HTMX 2 is the bigger thing right now :P

On Mon, Jan 8, 2024, 22:51 1cg @.***> wrote:

Still interested in this, but htmx 2.0 is taking up all my time. I promise I will get to it by the end of the month though.

— Reply to this email directly, view it on GitHub https://github.com/bigskysoftware/idiomorph/pull/25#issuecomment-1881801844, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA45DKQTXUMLWTNYAR7NTRTYNRL63AVCNFSM6AAAAABA5ZYUVOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBRHAYDCOBUGQ . You are receiving this because you authored the thread.Message ID: @.***>

1cg commented 5 months ago

going to look at this tonight