scala-js/scala-js-dom

Use `opaque type` instead of `sealed trait` for Scala 3

armanbilge opened this issue · 4 comments

@sjrd I looked into this a bit and doing this seems complicated by the fact that a sealed trait must be defined in the same file as its companion object (I don't think opaque types have the same rules).

So the only way I can see to do this would be to extract the companion object methods into a private[dom] trait that can be shared source between 2/3, and then extending it from the companion objects defined in both Scala 2 and Scala 3 sources seperately.

Seems a bit annoying but definitely do-able. Is there a better strategy?

sjrd commented

The companion objects of those sealed traits should have few members, that are basically constants. My idea was simply to copy-paste them.

Right, that works too 😆 any preference either way?

Do you mind if I try and wrap this up?

sjrd commented

The copy-paste makes for a better user-facing API, so I would go with that.