Handle shadow-cljs infern warnings

This commit is contained in:
Juho Teperi 2025-01-22 12:01:10 +02:00
parent 0370750a3f
commit bf82533028
2 changed files with 6 additions and 6 deletions

View file

@ -15,7 +15,7 @@
(defn query-params (defn query-params
"Given goog.Uri, read query parameters into a Clojure map." "Given goog.Uri, read query parameters into a Clojure map."
[^goog.Uri uri] [^goog.Uri uri]
(let [q (.getQueryData uri)] (let [^goog.Uri.QueryData q (.getQueryData uri)]
(->> q (->> q
(.getKeys) (.getKeys)
(map (juxt keyword #(query-param q %))) (map (juxt keyword #(query-param q %)))
@ -58,7 +58,7 @@
:on-coercion-error - a sideeffecting fn of `match exception -> nil`" :on-coercion-error - a sideeffecting fn of `match exception -> nil`"
([router path] (match-by-path router path nil)) ([router path] (match-by-path router path nil))
([router path {:keys [on-coercion-error]}] ([router path {:keys [on-coercion-error]}]
(let [uri (.parse goog.Uri path) (let [^goog.Uri uri (.parse goog.Uri path)
coerce! (if on-coercion-error coerce! (if on-coercion-error
(fn [match] (fn [match]
(try (coercion/coerce! match) (try (coercion/coerce! match)

View file

@ -65,7 +65,7 @@
(defn- event-target (defn- event-target
"Read event's target from composed path to get shadow dom working, "Read event's target from composed path to get shadow dom working,
fallback to target property if not available" fallback to target property if not available"
[event] [^goog.events.BrowserEvent event]
(let [original-event (.getBrowserEvent event)] (let [original-event (.getBrowserEvent event)]
(if (exists? (.-composedPath original-event)) (if (exists? (.-composedPath original-event))
(aget (.composedPath original-event) 0) (aget (.composedPath original-event) 0)
@ -76,9 +76,9 @@
should be ignored. This logic will ignore the event should be ignored. This logic will ignore the event
if anchor href matches the route tree, and in this case if anchor href matches the route tree, and in this case
the page location is updated using History API." the page location is updated using History API."
[router e el uri] [router e el ^goog.Uri uri]
(let [current-domain (if (exists? js/location) (let [current-domain (if (exists? js/location)
(.getDomain (.parse goog.Uri js/location)))] (.getDomain ^goog.Uri (.parse goog.Uri js/location)))]
(and (or (and (not (.hasScheme uri)) (not (.hasDomain uri))) (and (or (and (not (.hasScheme uri)) (not (.hasDomain uri)))
(= current-domain (.getDomain uri))) (= current-domain (.getDomain uri)))
(not (.-altKey e)) (not (.-altKey e))
@ -110,7 +110,7 @@
ignore-anchor-click (fn [e] ignore-anchor-click (fn [e]
;; Returns the next matching ancestor of event target ;; Returns the next matching ancestor of event target
(when-let [el (closest-by-tag (event-target e) "a")] (when-let [el (closest-by-tag (event-target e) "a")]
(let [uri (.parse goog.Uri (.-href el))] (let [^goog.Uri uri (.parse goog.Uri (.-href el))]
(when (ignore-anchor-click-predicate router e el uri) (when (ignore-anchor-click-predicate router e el uri)
(.preventDefault e) (.preventDefault e)
(let [path (str (.getPath uri) (let [path (str (.getPath uri)