darklang / rescript-tea

The Elm Architecture for Rescript
Other
119 stars 9 forks source link

want to help #57

Closed xudaotutou closed 1 year ago

xudaotutou commented 1 year ago
We've found a bug for you!
  D:\dev\code\rescript\tauri-rescript-tea-template\src\Main.res:7:25-27

  5 │
  6 │ switch app {
  7 │ | Some(app) => App.main(app)
  8 │ | None => ()
  9 │ }

  This has type:
    Dom.element (defined as
      Dom.eventTarget_like<Dom._node<Dom._element<Dom._baseClass>>>)
  Somewhere wanted:
    Js.null_undefined<Dom.node> (defined as Js.nullable<Dom.node>)
// Main.res
open Webapi.Dom

let app = document->Document.getElementById("root")

switch app {
| Some(app) => App.main(app)
| None => ()
}
pbiggar commented 1 year ago

What is App.main here?

xudaotutou commented 1 year ago
pbiggar commented 1 year ago

Try this:

let element = document->Document.getElementById("root")
let node = Webapi.Dom.Element.asNode(element)
let app = Js.Null_undefined.return(node)
App.main(app)
xudaotutou commented 1 year ago

Thanks! It make compiling finish

let element = document->Document.getElementById("root")

switch element {
| Some(e) => {
    let node = Webapi.Dom.Element.asNode(e)
    let app = Js.Null_undefined.return(node)
    let _ = App.main(app, ())
  }
| None => ()
}