Fork me on GitHub
#clojurescript
<
2019-05-08
>
dazld08:05:13

morning! is there any way to typehint that a variable is of a certain native JS type? ie.. function / map / set..

dazld08:05:41

or that the object has properties / methods that derive from a native type available

dazld08:05:46

(if you’re mixing)

art08:05:23

@dazld you mean something like

(defn foo [^number x]
  (inc x))
?

dazld08:05:37

oh, let me try just function

dazld08:05:54

na, that doesn’t work

dazld08:05:38

the code is all fine, this is just a cursive thing

dazld08:05:30

I’m guessing would need externs for the native JS types, maybe?

dazld08:05:25

i’m gobj/geting something, which is a function

dazld08:05:39

and wanted to hint that it has call/apply/bind etc

art08:05:36

Just guessing – doesn’t ^js/Function work? Otherwise you’ll need to go with externs

Ferdi14:05:05

good evening! i am currently working with the ' [org.clojure/data.xml "0.2.0-alpha6"]' lib. And with the following code ' (xml/emit-str (xml/element :foo:bar {} "baz")) ' i getting NamespaceError:. is their a work around?

dpsutton16:05:20

it works just fine for me

(clojure.data.xml/element :foo:bar {} "baz")
{:tag :foo:bar, :attrs {}, :content ("baz")}

dpsutton16:05:32

are you sure you requried [clojure.data.xml :as xml]?

hmaurer14:05:03

Are many people using ClojureScript on the server? Just curious, as it seems to have a couple of benefits over Clojure (e.g. no JVM => lighter on resources / boot time)

lilactown14:05:33

we do, but it’s definitely a bit rougher in terms of dev experience

hmaurer14:05:54

@lilactown in what ways? error messages etc?

lilactown14:05:39

errors are about the same, but it’s harder for newbies to get a REPL (we rely on hot reload a lot) and there just aren’t a lot of libraries

lilactown15:05:08

the only reason I would suggest it is if you really really want to use React SSR

hmaurer15:05:43

that was your case I assume?

Dustin Getz15:05:00

Hyperfiddle runs clojurescript in aws lambda

lilactown15:05:03

like it’s not bad, but Clojure is definitely a nicer experience

hmaurer15:05:37

@dustingetz oh; my usecase would be lambda a well

lilactown15:05:01

ah, if you need lambda then yes, CLJS would probably be better

lilactown15:05:26

last time I tried Clojure on a lambda (~1 yr ago) it had a 5-15s cold start time 😬

hmaurer15:05:19

GraalVM seems like another option, but I haven’t tried it out

lilactown15:05:29

is there a way to get CLJS to ignore deprecation warning for a specific instance?

lilactown15:05:46

ex I have a function foo that, just this ONE TIME, I want to use without warning

lilactown15:05:05

(right now shadow-cljs is blocking compilation due to it, and I don’t want to turn off warnings entirely)

thheller17:05:51

@lilactown you can set :devtools {:ignore-warnings true} so it doesn't block reloading

lilactown17:05:50

yeah I wanted to avoid ignoring everything

lilactown17:05:06

it’s fine I just copy + pasted the fn and removed the deprecation 😛

dpsutton18:05:14

I need to add externs for google recaptcha. Work already has some written for other things so I cannot use infer-externs as the guide suggests. In this case, where can I find some official documentation so that I can write these externs and not just mimic what exists?

Jacob Haag19:05:47

Has anyone had issues when using [cljsjs/fuse "2.6.2-0"] with advanced optimizations? When I deploy my app with :optimizations :advanced I get the following error relating to fuse.

app.js:1537 Uncaught TypeError: Cannot read property 'substring' of undefined
    at Nfa (app.js:1537)
    at app.js:426
    at app.js:425
    at app.js:275
    at Array.sort (<anonymous>)
    at hb (app.js:275)
    at kb (app.js:275)
    at Hg (app.js:425)
    at Kg (app.js:426)
    at Jg (app.js:425)

souenzzo20:05:24

@jacobhaag17 you can enable source-maps in your minified builds https://clojurescript.org/reference/compiler-options#source-map Then the browser will tell where the code throws.

👍 4
dpsutton20:05:06

there's also https://clojurescript.org/reference/compiler-options#pseudo-names which promises > determines whether readable names are emitted. This can be useful when debugging issues in the optimized JavaScript and can aid in finding missing externs. Defaults to false.

👍 4