I’m getting: ```Type mismatch: inferred type is or...
# react
p
I’m getting:
Copy code
Type mismatch: inferred type is org.w3c.dom.Element but dom.Element was expected
with this code:
Copy code
fun main() {
    createRoot(document.createElement("div").also { document.body!!.appendChild(it) })
        .render(App.create())
}
when bumping from kotlin-wrappers pre.430 to pre.431. What’s the new API? could you update kotlin-mui-showcase?
1
CC @turansky
b
I guess mui has its own dom api wrappers
You can always unsafeCast()
p
yeah, but technically it’s a breaking change in some basic, frequently used API - would be good to present a migration path
t
You can always unsafeCast()
No please! 🙂
I guess mui has its own dom api wrappers
DOM API in
kotlin-browser
- is what we use for all wrappers without exceptions. For example update it will be required some time.
b
Is it more covered than stdlib bindings?
t
Yes, we need all Browser API! 🙂
For some parts we use aliases on
stdlib-js
(
media
for example)
It’s for migration check, because in project we disable
org.w3c.*
imports
p
what’s the recommendation about using newest versions of kotlin-wrappers? should I stay on the old version until the types mismatch is resolved? is it tracked somewhere?
t
Early birds will have less problems :)
And less
!!
p
could you show an example how it should work in the newest version?
I’m starting from scratch actually
t
body
is non-null now
p
I mean:
Copy code
Type mismatch.
Required: dom.Element
Found: org.w3c.dom.Element
b
Use document.getElementById from kotlin-browser or unsafeCast
i.e. either change the way you obtain the element or convert it before passing in to the function
Cleanest solution would be to avoid org.w3c from stdlib and look for matching apis in dom. package
t
dom
- isn’t single package
b
I know, my point was to use apis from wrappers and avoid mixing them with stdlib alternatives where possible
t
Yes, it’s how it works
message has been deleted
And more packages in
dom
and
media
Exclude list:
codeInsightSettings.xml
Copy code
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="JavaProjectCodeInsightSettings">
    <excluded-names>
      <name>kotlin.browser.*</name>
      <name>kotlinx.browser.*</name>
      <name>kotlinx.dom.*</name>
      <name>org.khronos.*</name>
      <name>org.w3c.*</name>
    </excluded-names>
  </component>
</project>
MUI start point
Copy code
import browser.document
import dom.html.HTML.div
import dom.html.createElement
import react.create
import react.dom.client.createRoot


private fun main() {
    val container = document.createElement(div)
    document.body.appendChild(container)

    createRoot(container)
        .render(Application.create())
}
a
Hi @Piotr Krzemiński, showcases were updated, please take a look.
547 Views