This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-20
Channels
- # announcements (1)
- # beginners (65)
- # calva (16)
- # cider (44)
- # clara (16)
- # clojure (84)
- # clojure-dev (48)
- # clojure-europe (5)
- # clojure-finland (4)
- # clojure-houston (1)
- # clojure-italy (19)
- # clojure-nl (27)
- # clojure-russia (6)
- # clojure-spec (37)
- # clojure-uk (123)
- # clojured (11)
- # clojurescript (21)
- # datomic (40)
- # duct (4)
- # emacs (6)
- # figwheel (4)
- # figwheel-main (5)
- # fulcro (34)
- # jackdaw (8)
- # juxt (117)
- # kaocha (3)
- # klipse (1)
- # leiningen (33)
- # luminus (2)
- # nyc (3)
- # off-topic (29)
- # om (1)
- # pedestal (7)
- # planck (4)
- # re-frame (27)
- # reagent (8)
- # reitit (5)
- # rum (2)
- # shadow-cljs (428)
- # spacemacs (5)
- # tools-deps (15)
- # yada (6)
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.
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
so, this worked — using goog.reflect
to get Clojure’s lookup semantics working with Closure-renamable keys:
you are supposed to pass the object you are going to use the property on when calling reflectProperty
and you might be right, at first I tried passing in the object but then in my initial tests it didn’t matter
I would not be surprised if this hack breaks with certain kinds of typed objects but i haven’t found that case yet
yeah it might be fine but I'd be careful. otherwise you are just replacing one externs issue with another 😉
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
did you add another (deftype Y [bar foo])
and test that? foo
will likely get a different name there
maybe it gets the same name. not actually sure, the compiler pass for this is weird 🙂
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"))