This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-03
Channels
- # adventofcode (2)
- # announcements (1)
- # asami (35)
- # babashka (67)
- # beginners (97)
- # cherry (3)
- # clj-yaml (3)
- # cljsrn (9)
- # clojure (44)
- # clojure-dev (34)
- # clojure-europe (13)
- # clojure-gamedev (1)
- # clojure-norway (10)
- # clojure-uk (2)
- # clojurescript (24)
- # clr (1)
- # conjure (18)
- # cursive (4)
- # datalevin (3)
- # emacs (6)
- # graalvm (9)
- # graphql (1)
- # introduce-yourself (1)
- # malli (7)
- # nrepl (3)
- # portal (1)
- # quil (2)
- # reagent (1)
- # reitit (21)
- # releases (1)
- # reveal (11)
- # ring (2)
- # shadow-cljs (17)
- # sql (24)
- # vim (4)
Today was the first time i've run into a type related issue (or so it seems):
(ns my-ns
(:require
[goog.positioning :as gpositioning]
(:import
[goog.positioning OverflowStatus])
(let [status (gpositioning/positionAtCoordinate ...args) ; I return an int]
(bit-and status OveerflowStatus/FAILED)))
The above triggers a CLJS compiler warning:
cljs.core/bit-and, all arguments must be numbers, got [goog.positioning.OverflowStatus nil] instead
I can resolve by adding a type hint to the let binding (`^number status ...`), but just curious if anyone has seen something like this before.True. That's not where the warning comes from, but thanks!
Got interested and started fiddling and trying to do a minimal repro. 🙂 This is not enough to cause a warning
(defn testing []
OverflowStatus/FAILED)
(let [status (testing)]
(bit-and 1 status))
correct. That's because status
needs to be (gpositioning/positionAtCoordinate ...args)
(or at the least a function which returns an Overflow..but there is probably more to it because your example didn't work)
(let [status (gpositioning/getPositionAtCoordinate
(gmath/Coordinate. 1 2)
(gmath/Size. 100 200)
Corner/TOP_LEFT)]
(bit-and OverflowStatus/ADJUSTED_X status))
Whats in the code block in the original message 🙂
Anyways, I’m not seeing the warning with the latest example I posted. It’s probably doing nonsense because I just tried to feed the function something.
you want positionAtCoordinate
or positionAtAnchor
Something weird definitely here. closure reference docs show the first and second arg types as > (https://google.github.io/closure-library/api/goog.math.Coordinate.html|null) > (Element|null)
I see cljs has no amap
so how do I map over a #js
array? Do I need to (.map <js array>)
? Thx!
Ah, there is amap! It is just missing from https://cljs.info/cheatsheet/ for some reason…
Ah, I believed I got an error when I tried that but you are right, it works. Thank you!
trying to resurrect an old attempt at emscripten interop on a cljs project, but trying to restart a repl via clj -M -m cljs.main -co build.edn
is resulting in a cryptic Execution error at cljs.vendor.clojure.data.json/read-object ... JSON error empty entry in object is not allowed
-- anyone get this before and know what it's pointing to?