Fork me on GitHub
Richard Bowen05:12:43

Hey. What's a good library with ClojureScript for handling requests; GET, POST, PUT, etc..


I've been using that one for a long time and it hasn't disappointed me.


also venerable - which has node.js support, haven't found many libs that do


I’m getting a warning when compiling the following code:

cljs.core/-, all arguments must be numbers, got [#{js/clj-nil clj-nil} #{js/clj-nil clj-nil}] instead

  (- (ocall scale :invert translate-delta) (ocall scale :invert 0))
I expected that I could fix it like this:
(- ^js/number (ocall scale :invert translate-delta) ^js/number (ocall scale :invert 0))
But that gives me exactly the same warning. What am I missing?


Are you sure that these calls are returning numbers (ocall scale :invert translate-delta) (ocall scale :invert 0) based on warning it seems like they're returning nil instead.


Or w/e {js/clj-nil clj-nil} is (which doesn't appear to be a number).


I don't believe this is based on runtime values. This is the cljs compiler thinking these functions return nil (and maybe they do but this is metadata and tags based)


They definitely return numbers. The code works perfectly. But I'd like to be warning clean if possible?


(The functions, BTW, are from Vega).


are you on a recent or most recent ClojureScript?

Christian Johansen21:12:50

If I evaluate (type {}) I see cljs.core/PersistentArrayMap. Is there some way to get that symbol from a value? (str (type {})) returns the function’s toString from what I can tell, there is no meta, and (.-name (type {})) returns an empty string. Other things I can do?


Just in case - why do you want to do that?

Christian Johansen21:12:10

I’m working on some developer tooling 🙃


(pr-str (type {}))


(no clue whether it'll work in an optimized build)

Christian Johansen21:12:54

ah, of course, why didn’t I think of that :man-facepalming:

Christian Johansen21:12:22

optimized build is not highly relevant for this, but I’ll remember to look into it


If it interests anybody, I got a CLJS pREPL working inside JVM unit tests so you can eval CLJS expressions while testing from the JVM. This is useful for the cljs-math lib to compare Node.js results to the JVM results.

👍 1

you don't need sockets really. can just setup streams directly and skip all the network stuff


I basically copied something from the babashka tests which also has a prepl and reused that


@dpsutton this is with 1.10.893.


to diagnose, if you replace the call sites with (or (ocall scale ...) 0) does the warning go away?


Yes, that does make it go away.


Then i think it is a bug in the type inference going on. You can use this or hack, or I think there’s a way to turn off particular warnings. You could also create an issue on, ideally with a minimum reproduction. Simple deps.edn, with that single dep, or ideally just copy the functionality that recreates the issue, and keep removing extraneous bits until a simple reproduction exists


Cool. Will do 👍 Thanks!