solid icon indicating copy to clipboard operation
solid copied to clipboard

(Typescript) Expose classList type

Open marvin-j97 opened this issue 1 year ago • 4 comments

Currently exposing classList as a prop requires a custom type. It would be better to create a "ClassList" type definition, use that everywhere and expose it. PR following shortly.

marvin-j97 avatar Dec 10 '24 16:12 marvin-j97

We are in the process of meditating if classList should be deprecated, replaced by something else (such a super powered class[class behaving as classlist]/clsx equivalent) or just plainly suggest to use clsx instead, or maybe even leave it as is.

It has issues like defining both class and classList overwrites each other in un/predictable ways when stuff is dynamic. Specially when used in spreads(spreading before or after setting class as attribute?), when effects run out of the expected order(there are no expectation on the order effects run), and it has issues with SSR too.

I am probably missing some other situation. I meant to investigate this. While I somewhat understand the issue, I am not confident enough about its problems (it only happens in some circumstances and most of the time is not an issue or a big deal), and I am also not authoritative enough to decide over its future.

btw, the typings are in https://github.com/ryansolid/dom-expressions/blob/main/packages/dom-expressions/src/jsx.d.ts

I mentioned all of the above because we do not seem to be sure about its future, so you can consider

titoBouzout avatar Dec 16 '24 15:12 titoBouzout

I think deprecating or removing classList is irrelevant. It will stay in 1.x anyway (removing it would be a breaking change), so exposing its type makes sense I think.

marvin-j97 avatar Jan 08 '25 21:01 marvin-j97

I'm just not sure what package should export the type. I'm thinking solid/web? If so, then: https://github.com/solidjs/solid/pull/2401

marvin-j97 avatar Jan 08 '25 21:01 marvin-j97

If classList ends up being deprecated, it should be easy to write a Lint rule for Biome (and probably eslint too, but I'm not involved in that) to recommend using clsx or similar over it.

marvin-j97 avatar Feb 21 '25 19:02 marvin-j97