This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-03
Channels
hi guys
how could i navigate to specific div in the page from clojurescript?
@abdullahibra what is dommy
? are you sure you are calling that right?
@thheller [prismatic/dommy "1.1.0"]
[elem ^boolean align-with-top?]
it takes two args
elem and align-with-top? as boolean type
yeah but you are calling it with elem
and the clj->js
result (which is not a boolean)
oh right
maybe this was old version
(defn scroll-to-id
[target-id]
(-> (js/document.getElementById target-id)
(.scrollIntoView #js {:behavior "smooth" :inline "nearest"})))
that's good
can i scroll to top of div?
inline "start"
@thheller thanks 🙂
that's the right params {:behavior "smooth" :block "end" :inline "nearest"}
How do we use type hints in Clojurescript and how does it relate with type inference?
I am running this code snippet on version 1.10.516
:
(defn bar [^number x]
(inc x))
(bar "abc")
And I don’t get any warning.
While the following snippet creates a warning
(inc "abc")
cljs.core/+, all arguments must be numbers, got [string number] instead
@viebel pretty sure that is reserved to special js forms currently and not supported via type hints
@thheller Is there a support for type hints in cljs?
@mfikes Under what conditions a warning about argument type is emitted?
@viebel The core numeric macro-functions do this. Outside of this I’m struggling to think of any other specific examples.
@mfikes I see. Any idea why in my 1st example above no warning is emitted?
@viebel Because ClojureScript doesn't generally use type information to perform type checking. There was an experiment that, as an aside, involved adding generic type checking (https://gist.github.com/mfikes/1e2341b48b882587500547f6ba19279d), but ClojureScript probably isn't pursuing that direction.
Hmmm @mfikes So what is the big story with type inference?
ClojureScript has always had basic type inference, and the algorithms have been improving, so that more types are inferred. This is especially true over the past several releases, IMHO.
I understand that the algorithms are improving. My question is what value does it bring to developers?
Is it in terms of type checking or more efficient transpiled code or something else?
Any interesting example to share?
@mfikes excellent. I am looking forward to watch the video of your talk