Fork me on GitHub
#malli
<
2021-12-22
>
steveb8n02:12:59

Q: I have a typescript project which can expose react prop types. I’m wondering if there’s a way to convert these types to Malli using some kind of tooling? I don’t mind building the tool and submitting a PR if there is a way. Any typescript experts have ideas for this?

steveb8n03:12:10

background: I have a contractor building react components in Storybook/typescript which I use in a re-frame app. This workflow is huge win

steveb8n03:12:40

if I can figure out types -> Malli, I can enhance the testing story as well

steveb8n05:12:35

I’m a typescript/babel noob so I need to figure out how to expose the types and then interop to generate Malli

Tiago Dall'Oca14:03:10

I need to show up here more often haha

Tiago Dall'Oca14:03:40

yess, I'm working on it 🙂 (slowly)

Ivan Fedorov14:12:52

Is this normal that :e.order/shipping doesn’t resolve into a schema here? Or maybe I lost some understanding

(def registry:case
  {:e.order/shipping
   [:map [:address string?]]
   :e/order
   [:map
    [:shipping-lines
     [:vector [:ref :e.order/shipping]]]]})

(def schema:customer-order-case
  (m/schema
    [:schema
     {:registry registry:case}
     :e/order]))

(comment
  (-> (m/deref-all schema:customer-order-case)
      (m/children)
      (last) (last)
      (m/children) first ; -> [:ref :e.order/shipping]
      (m/children) first type))

;; comment block evals to a keyword

Ivan Fedorov14:12:29

ok, I got it, I have to m/deref a [:ref :x] block, not :x itself