alexnault/classix

TypeError using Preact

Closed this issue · 3 comments

When using with preact@10.16.0, I get the following TypeError:

Argument of type 'string | SignalLike<string | undefined> | undefined' is not assignable to parameter of type 'Argument'.
Type 'SignalLike<string | undefined>' is not assignable to type 'Argument'.ts(2345)

Screenshot 2023-07-21 220303

Can you possibly fix this? Or do you have a solution/workaround?

Hey @jrson83! Thanks for submitting this issue.

I'll have a look. I just need your code snippet with the VSCode tooltip opened please :)

I don't have experience with Preact, but from my understanding, you would need to either:

  • A: compute the className signal to a primitive string before passing it to classix
  • B: change the className type to string | undefined

Classix can't handle signals from Preact since it's "UI library"-agnostic. Does that make sense?

You are right! This is OK. Thanks for the response, feel free to close the issue.

// is OK
className={cx(
  className as string,
  uppercase && 'uppercase',
  scale !== 'base' && `btn-${scale}`
)}