A non-native JS trait cannot have constructor parameters

Lately i ran into this:

import scala.scalajs.js
trait A(val a: Int) extends js.Object

gives:

A non-native JS trait cannot have constructor parameters

Should this be added to the list of Restrictions in the documentation or am I missing something? (Btw, this is mostly not a big deal since can just define it as a field.)

Technically it is a consequence of

Non-native JS traits cannot declare concrete term members (i.e., they must all be abstract) unless their right-hand-side is exactly = js.undefined.

since constructor parameters are concrete term members.

But PR welcome if you think this deserves a dedicated clarification.

1 Like