Fork me on GitHub
#clojurescript
<
2019-02-20
>
dpsutton02:02:02

does :source-paths of the :cljsbuild put those paths on the classpath? I would think it would but I'm getting errors unless the paths are also in :source_paths at the top level for the project.

dpsutton04:02:27

figured it out. when using CIDER to jack in, it only sees the classpath and figwheel uses the cljs build info but cannot add these things to the classpath at this point. However, when started from a task like lein figwheel dev it can see these extra paths

mhuebert16:02:48

so, this worked — using goog.reflect to get Clojure’s lookup semantics working with Closure-renamable keys:

upside_down_parrot 5
thheller17:02:16

you are supposed to pass the object you are going to use the property on when calling reflectProperty

thheller17:02:02

(goog.object/get thing (goog.reflect/objectProperty "prop" thing))

thheller17:02:09

otherwise you might get inaccurate results I think?

mhuebert18:02:18

I was looking at that

mhuebert18:02:55

and you might be right, at first I tried passing in the object but then in my initial tests it didn’t matter

mhuebert18:02:55

I would not be surprised if this hack breaks with certain kinds of typed objects but i haven’t found that case yet

thheller18:02:20

yeah it might be fine but I'd be careful. otherwise you are just replacing one externs issue with another 😉

mhuebert18:02:53

eg. I’m using this in a lib with a (deftype X [foo] ...) where foo is being renamed, and the key I get back from (reflect/objectProperty "foo" _obj) is correct even though I didn’t pass it my instance of X

thheller18:02:21

did you add another (deftype Y [bar foo]) and test that? foo will likely get a different name there

thheller18:02:09

maybe it gets the same name. not actually sure, the compiler pass for this is weird 🙂

mhuebert18:02:20

I will add some tests for that

mhuebert19:02:56

so I added these tests:

(deftype A [someProperty])
(deftype B [someProperty])
(deftype C [someProperty])

(let [a (new A "x")
      b (new B "x")
      c (new C "x")
      d (doto #js{}
          (-> .-someProperty (set! "x")))]

  (is (= (reflect/objectProperty "someProperty" a)
         (reflect/objectProperty "someProperty" b)
         (reflect/objectProperty "someProperty" c)
         (reflect/objectProperty "someProperty" d))
      "goog.reflect returns the same property key for different types")

  (is (= (j/get a .-someProperty)
         (j/get b .-someProperty)
         (j/get c .-someProperty)
         (j/get d .-someProperty)
         "x")
      "host-interop keys work across different types using the same keys"))

mhuebert19:02:14

will try to think of other cases

mhuebert20:02:08

I haven’t looked at exactly what options the ClosureScript compiler is passing to GC

mhuebert18:02:15

FWIW I rewrote the macros so the correct thing is passed into reflect/objectProperty