Fork me on GitHub
#shadow-cljs
<
2019-12-28
>
grav21:12:00

Messing with typehinting and the aws sdk. I'm trying to instantiate an SES thingy like this

(def ^js aws (js/require "aws-sdk"))
(defn my-handler ...
  (let [ses (aws.SES.)]
...
which on runtime errors out with "TypeError: wn.ld is not a constructor". Using shadow-cljs' simple externs, I can get it to work by simply adding the string "`SES`" to externs/my-build.txt, but I'd really like to get it working using typehinting. So far, I've tried:
(let [ses ^js (aws.SES.) ...
and
(let [ses (new ^js aws.SES)
but to no avail

martin hablak21:12:28

hello, is it possible to use nrepl-refactor or any kind of refactoring with shadow-cljs? (iā€™m using emacs)

aisamu21:12:37

Yes! Here's an example setup if you're using tools-cli:

;; ~/.clojure/deps.edn
{:deps {nrepl/nrepl {:mvn/version "0.7.0-alpha3"}
        cider/cider-nrepl {:mvn/version "0.23.0-SNAPSHOT"}
        refactor-nrepl {:mvn/version "2.5.0-SNAPSHOT"}}}

;; ~/.nrepl
{:middleware [refactor-nrepl.middleware/wrap-refactor]}

thheller22:12:48

@grav use (:require ["aws-sdk" :as aws]) in your ns and then (aws/SES.) that should take care of it

grav22:12:05

@U05224H0W Thanks a bunch. Externs inference is black magic to me ... good to have a wizard at hand šŸ™‚

thheller22:12:27

@martin.hablak no clue. I don't use emacs but I'd guess that adding the dependency+middleware should make it work.

šŸ‘ 1