Type 'VNode[]' is not assignable to type 'ReactFragment'
ozcanxbreeze opened this issue · 7 comments
in packages/src/views the error 'Type 'VNode[]' is not assignable to type 'ReactFragment'' is thrown. This does not happen in the ecore example (https://github.com/eclipse-emfcloud/ecore-glsp).
It works in the browser but the error is shown while compiling the application. Might be something wrong with the dependencies or configuration files.
@martin-fleck-at Could you take a look at this?
@ozcanxbreeze I think it has to do with the different versions of React or Theia in Ecore GLSP. Ecore GLSP is using React 16 whereas we are using React 18 or there could be a version issue somewhere. Just from a quick glance I could not really detect the problem as the same code seems to work in other places. As a workaround for now we can definitely use {context.renderChildren(node) as ReactNode}
to make sure Typescript accepts it. But I'll look into this a bit more just to see what could be causing this and post another update.
Btw, I found a really nice project that provides a UML editor based on GLSP which also looks similar to what you want to achieve: https://github.com/borkdominik/bigUML. I have not really tried working with it, just saw it and thought it might be of interest to you.
@ozcanxbreeze I asked around with my colleagues and it seems that is a known issue of combining Sprotty (from GLSP) with React, see eclipse-sprotty/sprotty#178 and theia-ide/sprotty#203, that only showed up with React 18. I tried setting the types to []
as suggested in one of the tickets but it did not make any difference for me. So either we separate out the GLSP views into a separate package with different configurations to see if that works or we accept the explicit casting for now to make the typescript compiler happy.
Great, I think the explicit casting is fine for now. @harmen-xb what do you think?
@ozcanxbreeze I agree casting is fine. It's only a workaround for the IDE, the actual program works fine. Can you link the changeset where you added the cast in this issue, then it can be closed.
see #11
Done and also merged into the main branch