Fork me on GitHub

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.) ...
(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)


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]}


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


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


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

šŸ‘ 1