This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-05
Channels
- # announcements (8)
- # babashka (6)
- # beginners (55)
- # biff (8)
- # calva (11)
- # cider (4)
- # clj-kondo (6)
- # cljdoc (23)
- # cljs-dev (22)
- # clojure (89)
- # clojure-brasil (3)
- # clojure-europe (47)
- # clojure-indonesia (1)
- # clojure-nl (1)
- # clojure-spec (3)
- # clojure-uk (5)
- # clojurescript (67)
- # community-development (2)
- # conjure (29)
- # cursive (2)
- # datalog (29)
- # datomic (41)
- # defnpodcast (4)
- # emacs (15)
- # google-cloud (5)
- # holy-lambda (6)
- # hyperfiddle (3)
- # introduce-yourself (8)
- # jobs (1)
- # malli (19)
- # meander (41)
- # nrepl (1)
- # off-topic (30)
- # pathom (22)
- # polylith (30)
- # releases (1)
- # remote-jobs (4)
- # sci (4)
- # shadow-cljs (1)
- # spacemacs (7)
- # specter (3)
- # tools-build (16)
- # tools-deps (2)
@timothypratley looking at your issue, it appears this case is just missing - no test for this particular case - required JS lib fn invoke, (js/foo)
is tested and works - so it will be a good fix
I was doing something complicated, but then realized this can probably be fixed in the type inference part of the code only - https://github.com/clojure/clojurescript/pull/173/files
@timothypratley there is one potential enhancement - infer that any usage of method where we know the first argument is ^js
and the callback fn is inlined, we auto-hint the arguments to ^js
if the argument is a var - we warn if that var did not declare all its arguments as ^js
IMO that would be very helpful, and AFAIK then all scenarios are covered which is awesome.
Oh, just to correct myself, I don't think it would catch:
(-> (signInWithPopup auth google-provider)
(.then (fn [^js/firebase.firestore.UserCredential result]
(when (seq scopes)
(gauth/authorize (-> result (.-user) (.-email)))))))
because here the (fn [result] ...)
is called by promise instead of callback. :thinking_face:oh wow
sweet!!!
That's really cool.
not in scope for next release - but if nobody sees any problem with that (it seems OK to me at the moment) - can come at a later time (and would be experimental/optional until enough feedback is collected, i.e. :extern-infer-js-callbacks true
etc)
with CLJS-3373, you only need to switch to goog.object
inside callback handlers and you don't need all that redundant hinting
Thank you so much David! You rock 🙂
the only gap w/ callback externs infer would be higher order invokes, but I think we should probably warn on those since it's potential pothole anyway
My guess is that hinting ^js
on a function argument would probably be fine anyway (even though it isn't necessary); I don't think it would have any effect? :thinking_face: