Fork me on GitHub
#clojurescript
<
2021-12-02
>
popeye13:12:45

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 ?

p-himik13:12:01

The main website mentions a decent amount of materials: https://clojurescript.org/community/resources

🙌 1
paulbutcher21:12:46

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";

dsvFormat(";").parseRows(s);
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: https://github.com/d3/d3-dsv/blob/main/src/dsv.js#L155 I’d be very grateful for any pointers in the right direction.

lilactown21:12:04

what build tool are you using?

p-himik21:12:30

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

p-himik21:12:51

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.

lilactown21:12:10

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

paulbutcher21:12:44

I’m using Figwheel Main

p-himik21:12:04

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

paulbutcher21:12:27

So this?:

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

p-himik21:12:01

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.

paulbutcher21:12:18

Thanks - that looks to have done the trick 👍

👍 1