Fork me on GitHub

I started with the learning clojure script! and I started reading books of clojure script, But the books almost contains how clojure is writtern and its basic syntax's.. I wanted to understand how clojure script is written , Basically more about the clojure script! Can anyone guide me about learning clojureascript ?


The main website mentions a decent amount of materials:

🙌 1

I’m trying to call the d3-dsv library from ClojureScript and getting myself embroiled in externs issues. I’d appreciated some help working out how to fix them. I’m compiling with Figwheel Main with :auto-bundle set to :webpack (which implies :infer-externs). Specifically, I’m trying to write the equivalent of:

import {dsvFormat} from "d3-dsv";

I have this:
(ns ... (:require [d3-dsv :refer [dsvFormat]]))

(.parseRows (dsvFormat ";") s)
Which works just fine in a development build, but fails in a release build with:
Uncaught TypeError: LY.dsvFormat(...).Zk is not a function
And sure enough, if I set *warn-on-infer* then I see:
Cannot infer target type in expression (. (dsvFormat ";") parseRows s)
I’m damned if I know how to tell it what the right type is though, given that it’s the default export from this file: I’d be very grateful for any pointers in the right direction.


what build tool are you using?


I think by now all build tools support the ^js annotation, no?


So even if you don't know the type of x, if your compiler can't infer its type, you can just write ^js x.


i know shadow-cljs supports that, wasn't sure about vanilla clojurescript/figwheel


I’m using Figwheel Main


@U4YGF4NGM Yeah, ^js is in the CLJS compiler code.


So this?:

(.parseRows ^js (dsvFormat ";") s)


I think so, yeah. If that doesn't work for some reason, you can always assign the result of the inner (...) to a name and annotate that name.


Thanks - that looks to have done the trick 👍

👍 1