Fork me on GitHub

1. (resolve (symbol "max")) -> error: Argument to resolve must be a quoted symbol 2. (resolve 'max) -> working 3. (= 'max (symbol "max")) -> true 'max and (symbol "max") is same so #1 should work. but there is error. could u have any advice for me. or plz tell me any helpful link.


I think there are some work arounds by using cljs.analyzer.api/resolve , but it can be tricky


thanks i will check it.


I’m not sure you can use cljs.analyzer.api/resolve in cljs, I think it has to be used in a clojure macro called from cljs


since the var information is only available at compile time


ok. thanks your help.


I compiled my cljs app into an npm module using shadow-cljs and want to call it within a JS module. This JS module has access to an object with global scope controlling URL state, and, given the architecture of the broader system, I have to use that object within my cljs code and access some methods within it. Think something to the effect of:

# my js file
mycljs.init(router) // within js module, initializing app with said needed object

# in my cljs file
(defn init [router]
  ... logic whatever ...
  (.changePage router "someNewUrl"))
The problem is that this ... doesn't actually work. it complains there is no such function associated with the object (and, tellingly, the name is mangled in the console error logs--it complains there is no such function http://iq.Ga  or some sort). I have no issues accessing attributes, e.g.
(.-pathname router)
so I know I am at least converting the object properly. It's just the methods that are tripping it up. So... my next thought is perhaps I need to define externs, because the cljs code is mangling the method names (I think)? I think I'm a bit uncertain because it seems like most of the things online I see about using JS modules are assuming you are running things via cljs and have access to the NPM module. I am sort of doing the reverse--compiling my cljs, calling that in regular js, and passing that function a js object. The cljs code does not know the NPM module exists at all, only that it's supposed to receive an object.


@rbruehlman turn on externs inference. the compiler will tell you about things that are likely to be renamed and causing issues.


in your case probably just (defn init [^js router] ...)


perfect--that worked! thanks!

👍 4

Hello clojurians, I encountered the same problem as in for the past with the latest release of clojurescript. Am I supposed to duplicate implementations or is there a better way to do this ? thank you


@pbaille you cannot do what you do in Clojure because JavaScript doesn't have interfaces


btw it's better to ask Clojure(Script) questions here:


@dnolen thank you, i just wanted to be sure i was not missing something


one workaround is that you can extend-type default and in your implementation check to see if the thing satisfies some protocol