Fork me on GitHub
#fulcro
<
2022-04-07
>
roklenarcic15:04:14

I always forget how to properly use macros in CLJS, I am trying to use guardrails in CLJS with: (:require [com.fulcrologic.guardrails.core :refer [>defn => ?]]) and I keep getting “undeclared var” when compiling

roklenarcic18:04:49

Hm

[com.fulcrologic.guardrails.core :refer-macros [>defn ?] :refer [=>]]
doesn’t work either

roklenarcic18:04:30

Hm, it specifically fails for multiarity >defn. If I have

(>defn connect
  "My Docs"
  ([db-name rw?]
   [string? boolean? => #(satisfies? Storage %)]
   (connect db-name "fulcro" rw?))
  ([db-name store-name rw?]
   [string? string? boolean? => #(satisfies? Storage %)]
   (-> (create-fulcro-db db-name store-name)
       (p/then (fn [db] (->Connection db store-name rw?))))))
I will get warnings that db-name is undeclared, rw? is undeclared, store-name is undeclared. But if I delete one of the arities the >defn macro works

roklenarcic18:04:49

Or rather it gives another error…

roklenarcic19:04:49

Ok found the problem, apparently guardrails doesn’t like anon fns as spec:

[string? string? boolean? => #(satisfies? Storage %)]