thheller / shadow-cljs

ClojureScript compilation made easy
https://github.com/thheller/shadow-cljs
Eclipse Public License 1.0
2.23k stars 173 forks source link

(WARNING) Cannot infer target type in expression (. with-let -generation) #1181

Closed JanDornbusch closed 1 month ago

JanDornbusch commented 1 month ago

How to reproduce

Steps to reproduce: get a new computer (In my case Win11, which I am not allowed to change) and install everything fresh (old system runs on old versions without problems)

Preparing the test (I know some parameters superseded others)

lein new luminus tapp +reitit +aleph +shadow-cljs +kee-frame +re-frame +reagent +cljs +kibit
cd tapp
npm install 
code .

altering the version of luminus from 2.20.3 to be 2.28.7 (remember to do it in project.clj and package.json. Lookup the matching closure compiler version on clojars and set it accordingly. (Hopefully none of the other libraries cause the problem here)

Start shadow by:

lein with-profile +dev update-in :dependencies conj '[cider/cider-nrepl \"0.47.1\"]' -- run -m shadow.cljs.devtools.cli --npm -d cider/cider-nrepl:0.47.1 watch app tapp`

Do not forget tot startup the server separatly (will create another issue with the compability problem). First load of page succeeds. Open up the core.cljs of luminus project and just save it again the following warning will appear:

The Problem

WARNING in tapp/view.cljs
  12 |    title])
  13 | 
  14 | (defn navbar []
  15 |   (r/with-let [expanded? (r/atom false)]
---------^----------------------------------------------------------------------
Cannot infer target type in expression (. with-let72913 -generation)
--------------------------------------------------------------------------------
  16 |     [:nav.navbar.is-info>div.container
  17 |      [:div.navbar-brand
  18 |       [:a.navbar-item {:href "/" :style {:font-weight :bold}} "tapp"]
  19 |       [:span.navbar-burger.burger

When does it appear and how to solve?

As far I have tracked it down 2.20.16 was the last working version not warning about it, leading me to assume that it is not related to #753?

As it's out of the box template which solution might be the better one? Suspress the warning on macros like with-let of reagent? Or altering either luminus or reagents code to supply a propper type?

thheller commented 1 month ago

See https://github.com/reagent-project/reagent/issues/585

Since the ticket is closed I assume the warning will go away if you upgrade to the latest reagent version. shadow-cljs is working correctly here, so not really shadow-cljs related issue.

JanDornbusch commented 1 month ago

Thanks for pointing towards the solution. I wasn't sure and hadn't found that one, as some older versions were working probably without changing reagent I have to confess I hadn't checked there neither. My fault and apologies!