ThoughtWorksInc / Binding.scala

Reactive data-binding for Scala
https://javadoc.io/page/com.thoughtworks.binding/binding_2.13/latest/com/thoughtworks/binding/index.html
MIT License
1.59k stars 108 forks source link

Code in `ReadMe.md` failed for unkonow reason. #490

Closed djx314 closed 1 year ago

djx314 commented 1 year ago

Code Link

Dependencies:

libraryDependencies += "com.yang-bo"              %%% "html"    % "3.0.2"
libraryDependencies += "com.thoughtworks.binding" %%% "binding" % "12.2.0"

Plugins:

addSbtPlugin("org.scala-js"                      % "sbt-scalajs"              % "1.13.0")
addSbtPlugin("com.vmunier"                       % "sbt-web-scalajs"          % "1.2.0")
addSbtPlugin("com.typesafe.sbt"                  % "sbt-js-engine"            % "1.2.3")
addSbtPlugin("com.thoughtworks.sbt-scala-js-map" % "sbt-scala-js-map"         % "4.1.1")

Scala Version: 3.2.2

Message:

sbt:desu-video> prun
[info] scalafmt: Formatting 2 Scala sources (Path\desu-video\frontend\js)...
[info] scalafmt: Formatting 1 Scala sources (Path\desu-video\frontend\js)...
[info] scalafmt: Reformatted 1 Scala sources
[info] compiling 2 Scala sources to Path\desu-video\frontend\js\target\scala-3.2.2\classes ...
[error] -- [E007] Type Mismatch Error: Path\desu-video\frontend\js\src\main\scala\AA.scala:56:4 
[error] 56 |    html"""<tr>
[error]    |    ^
[error]    |Found:    com.thoughtworks.binding.Binding.BindingSeq[org.scalajs.dom.Node]
[error]    |Required: com.thoughtworks.binding.Binding[org.scalajs.dom.html.TableRow]
[error] 57 |      <td>${contact.name.bind}</td>
[error] 58 |      <td>${contact.email.bind}</td>
[error] 59 |      <td>${bindingButton(contact).bind}</td>
[error] 60 |    </tr>"""
[error]    |
[error]    | longer explanation available when compiling with `-explain`
[error] one error found
[info] scalafmt: Formatting 1 Scala sources (Path\desu-video\backend\desu-video-common)...
[error] (frontendJS / Compile / compileIncremental) Compilation failed
[error] Total time: 10 s, completed 2023-3-9 8:58:05
Atry commented 1 year ago

Would it work if you delete the return type like adf7ec7d4e97c9d77c44ce2db933edd7310db398

djx314 commented 1 year ago

emmm, it seems that it makes bindingTr as a BindingSeq and not a Binding[Node]

sbt:desu-video> 
sbt:desu-video> 
sbt:desu-video> frontendJS/clean
[success] Total time: 0 s, completed 2023-3-9 17:52:13
sbt:desu-video> 
sbt:desu-video> 
sbt:desu-video> prun
[info] scalafmt: Formatting 2 Scala sources (E:\programming\workspace\desu-video\frontend\js)...
[info] scalafmt: Formatting 2 Scala sources (E:\programming\workspace\desu-video\frontend\js)...
[info] compiling 2 Scala sources to E:\programming\workspace\desu-video\frontend\js\target\scala-3.2.2\classes ...
[error] -- [E008] Not Found Error: E:\programming\workspace\desu-video\frontend\js\src\main\scala\AA.scala:67:27 
[error] 67 |        bindingTr(contact).bind
[error]    |        ^^^^^^^^^^^^^^^^^^^^^^^
[error]    |value bind is not a member of com.thoughtworks.binding.Binding.BindingSeq[org.scalajs.dom.Node].
[error]    |An extension method was tried, but could not be fully constructed:
[error]    |
[error]    |    com.thoughtworks.dsl.Dsl.shift[com.thoughtworks.binding.Binding.Bind[Any], Any](
[error]    |      com.thoughtworks.binding.Binding.Bind[Any](DummyImplicit.dummyImplicit).apply(
[error]    |        AA.bindingTr(contact)
[error]    |      )
[error]    |    )
[error] -- Error: E:\programming\workspace\desu-video\frontend\js\src\main\scala\AA.scala:64:4 
[error]  64 |    html"""<table>
[error]     |    ^
[error]     |Require a HTML DOM expression, got interpolation expression com.thoughtworks.binding.Binding.BindingSeq[scala.Any]
[error]     |method watchableBindableSeq in trait LowPriorityBindableSeq2 does not match type com.thoughtworks.binding.bindable.BindableSeq.Lt[Value, org.scalajs.dom.Node]
[error]  65 |      <tbody>
[error]  66 |        ${for (contact <- contacts) yield {
[error]  67 |        bindingTr(contact).bind
[error]  68 |      }}
[error]  69 |      </tbody>
[error]  70 |    </table>"""
[error]     |---------------------------------------------------------------------------
[error]     |Inline stack trace
[error]     |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]     |This location contains code that was inlined from Reset.scala:113
[error]      ---------------------------------------------------------------------------
[error] two errors found
[info] scalafmt: Formatting 1 Scala sources (E:\programming\workspace\desu-video\backend\desu-video-common)...
[error] (frontendJS / Compile / compileIncremental) Compilation failed
[error] Total time: 4 s, completed 2023-3-9 17:52:19
sbt:desu-video> 
djx314 commented 1 year ago

Code

Atry commented 1 year ago

How about 21c86d8a245e12d7a3fe3bae69012acc039457b0?

djx314 commented 1 year ago

The same error. And change to this, it works, but the HTML seems not right.

图片

It seems that all the is miss and just add some Text Snippet to HTML, so I think the type BindingSeq[Node] means Binding[Seq[TextNode]].

djx314 commented 1 year ago

Code

Eager fix the problem in sbt-depts and now can reproduct the problem by run

sbt>frontendJS/compile
djx314 commented 1 year ago

The same error. And change to this, it works, but the HTML seems not right.

图片

It seems that all the is miss and just add some Text Snippet to HTML, so I think the type BindingSeq[Node] means Binding[Seq[TextNode]].

Error typo.

It seems that all the is miss and just add some Text Snippet to HTML, so I think the type BindingSeq[Node] means Binding[Seq[TextNode]].

It seems that all the HTML Tags is miss and just add some Text Snippet to HTML, so I think the type BindingSeq[Node] means Binding[Seq[TextNode]].

Atry commented 1 year ago

Fixed in https://github.com/Atry/html.scala/commit/d627afe0f63cdb3c6906b61c818094cf4c8bcbeb