Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upExport inner objects in Scala classes #4142
Comments
Thanks for opening the issue. Could you also post here what happens when adding |
The compiler complains |
As a workaround, it's possible to export a getter for the object instead: class ClassWithInnerObj {
val x = 1
@JSExport
def innerObj: innerObjInternal.type = innerObjInternal
object innerObjInternal extends js.Object {
val y = 2
}
} |
Thanks for the workaround. I use it in the adapter code generation of the ScalaTsPlugin. After this is fixed I would like to get rid of the workaround because it causes two members to be created in the TypeScript declaration file. There is the danger to access the 'object field' directly instead of the assigned value. |
In the following example the
innerObj
field is not set, i.e.new ClassWithInnerObj().innerObj
is undefined:The generated code contains only an assignment of
null
to the field. No other references exist in the generated code: