This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-05
Channels
- # architecture (23)
- # bangalore-clj (2)
- # beginners (93)
- # cider (27)
- # cljsjs (2)
- # clojure (66)
- # clojure-russia (9)
- # clojure-spec (28)
- # clojure-uk (3)
- # clojurescript (47)
- # cursive (2)
- # data-science (2)
- # datomic (10)
- # editors (9)
- # emacs (4)
- # figwheel (3)
- # figwheel-main (1)
- # hyperfiddle (2)
- # jobs (1)
- # nrepl (59)
- # off-topic (2)
- # onyx (10)
- # pedestal (1)
- # re-frame (13)
- # reagent (9)
- # reitit (17)
- # shadow-cljs (8)
- # tools-deps (4)
- # vim (2)
I'm trying to import an es6 javascript module using the instructions here: https://clojurescript.org/guides/javascript-modules
When I did I got the following error: Uncaught SyntaxError: 'super' keyword unexpected here
I reduced it to a simple test case with the following:
export class Greeter {
constructor(subject, salutation) {
this.subject = subject;
this.salutation = salutation;
}
greet() {
console.log(`${this.subject} ${this.salutation}!`);
}
}
export class HelloWorld extends Greeter {
constructor() {
super("Hello", "world");
}
}
I couldn't find anything on the Google Closure GitHub issues about issues with super
so I thought I'd post it here to see if anyone could help.parsing some text loaded by a web page. After 2 days I figured out that the strings are NOT java strings but javascript strings and so lots of clojure stuff I do isn't working.
@llsouder clojure.string is completely cross-platform. there’s occasionally little idiosyncracies but it’s very much corner cases
:thinking_face: @colinkahn are you getting that error at compile time or in the browser?
in the browser, from what I can tell the compiled code turns the constructor of the class into a normal function and the super call is no longer valid within it
let HelloWorld$$module$src$js$hello = function() {
super("Hello", "world")
};
I shortened the variable it outputs, but that's what the compiled result where the syntax error occursComparing the output to that generated here: https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520SIMPLE_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%2540formatting%2520pretty_print%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%252F%252F%2520ADD%2520YOUR%2520CODE%2520HERE%250Aexport%2520class%2520Greeter%2520%257B%250A%2520%2520constructor(subject%252C%2520salutation)%2520%257B%250A%2520%2520%2520%2520this.subject%2520%253D%2520subject%253B%250A%2520%2520%2520%2520this.salutation%2520%253D%2520salutation%253B%250A%2520%2520%257D%250A%250A%2520%2520greet()%2520%257B%250A%2520%2520%2520%2520console.log(%2560%2524%257Bthis.subject%257D%2520%2524%257Bthis.salutation%257D%2522!%2522%2560)%253B%250A%2520%2520%257D%250A%257D%250A%250Aexport%2520class%2520HelloWorld%2520extends%2520Greeter%2520%257B%250A%2520%2520constructor()%2520%257B%250A%2520%2520%2520%2520super(%2522Hello%2522%252C%2520%2522world%2522)%253B%250A%2520%2520%257D%250A%257D%250A%250A
Looks like the the $jscomp.inherit
function is not generated/used. Guessing ClojureScript is using an earlier version of the Closure compiler?
@colinkahn I haven’t looked at what is going on above, but ClojureScript master has a revision to update to the latest released Closure Compiler. Also, you can specify that version by explicitly overriding that dep in your project.
Apologies for the noob question: In ClojureScript, what's the correct pattern for defining two functions that call each other? I'm trying to do this now but getting a compiler error that the second function is not defined when it is called in the first function because the compiler hasn't reached that point in the file yet
The context here is that I'm writing a tree component with Reagent where there can be different types of tree nodes, using a render-node
function to decide which actual render function to use based on the tree node type
By the way @daviwil, this is called “mutual recursion”; it might make it easier to search for it 🙂

Thanks! I'm aware of the terminology and searched for that but didn't find any answers, thus I came here 😉
@daviwil if you don’t find any answers for a question like this in clojurescript, try clojure; afaik all of these things should behave similarly, and so have the same solution
Yeah, I wasn't sure if this was one of the subtle differences between Clojure and ClojureScript but I'll try that next time
Not trying to discourage you to ask here mind you; I do so all the time. Just a tip in case you want a quicker solution 🙂
Hey folks, I've got some example code over in #architecture about managing memory over SharedArrayBuffers in CLJS. It's sort of a garbage collection problem. Anybody built a slab allocator before?
Hi, I am thinking about make small module (100 lines?) to simplify use form validation messages for user. Like error should appear after user touch / lost focus the required field not before. It matters especially about empty fields. Errors messages based on spec validation. In this examples I use simple messages, but it could also look like:
{::sc/email "Typo? It doesn't look valid."
::sc/password "Password is required."
::sc/password-difficulty "Too easy"
::sc/password-length "Too short"}
Does it make sense? Would you like to use it? Maybe solution like this already exist? I didn’t find one.
(defn log-in []
(let [specs->msg {::sc/email "Typo? It doesn't look valid."
::sc/password "Password is required."}
names->spec {:email ::sc/email
:password ::sc/password}
names->value (r/atom {:email ""
:password ""})
form (form/init-form names->value names->spec specs->msg)
value->form (form/fn-value->form form)
name->touched (form/fn-name->touched form)
form-valid? (form/fn-form-valid? form)]
(fn []
(let [email-error? (form/show-error? form :email)
password-error? (form/show-error? form :password)]
[:div
[:form
[mui/text-field
{:on-change value->form
:on-blur name->touched
:error email-error?
:helper-text (if email-error?
(form/get-error form :email)
" ")
:name "email"
:label "Email"}]
[mui/text-field
{:on-change value->form
:on-blur name->touched
:error password-error?
:helper-text (if password-error?
(form/get-error form :password)
" ")
:type "password"
:name "password"
:label "Password"}]
[:div
[mui/button
{:variant "raised"
:color "primary"
:on-click #(when (form-valid?)
(re-frame/dispatch [:log-user @names->value]))}
"Log in"]]]]))))
I’m embarrassed about this newbie question — but I just upgraded to ClojureScript 1.10.339 (to try out Ghostwheel by @clojurians.net!) and now I’m get a bunch of type inference errors for functions like GetElementByID and preventDefault. What is the best way to get definitions of all these functions? (or maybe I should broaden the question to: “how do I make all these warnings go away?” 🙂 Thanks in advance!!!
Cannot resolve property getElementById for inferred type js/HTMLDocument in expression
Ex: (.getElementById js/document "app")
Cannot infer target type in expression (. event preventDefault)
Ex: (.preventDefault event)
Hello everyone 👋 I’m trying to get a Clojure linter into VSCode and am using Calva. Has anyone encountered this error (or know how to interpret it?)
Caused by: java.lang.IllegalStateException: Attempting to call unbound fn: #'nrepl.middleware/set-descriptor!
I followed these directions https://shadow-cljs.github.io/docs/UsersGuide.html#_calva_vs_code and encountered the error upon adding [cider/cider-nrepl]
to my dependencies.my best guess: I didn’t have my server running (I restarted it to add this dependency) and it looks like the middleware trips because it expects the nrepl to be up already.
@UC2FSP5KK cider-nrepl
is in a weird spot currently due to some breaking changes in the upgrade to nrepl 0.4
you can downgrade shadow-cljs to 2.4.24
which should still work with the old cider release
awesome thank you @U05224H0W I’ll try it out
Many moons ago, I added to certain namespaces (set! *warn-on-infer* true)
to detect extern errors (things that would get minimized away by the Closure compiler).
Getting warnings on getElementById
and preventDefault
didn’t happen with ClojureScript 1.9.946. Thanks!
@genekim you need to typehint event
. in shadow you’d just do ^js event
— i’m not sure how it works with the standard compiler
Alas, @lee.justin.m, adding ^js event
typehint does not make the warnings go away in the standard CLJS compiler. 😞 Thanks, though!
you should probably post on stackoverflow. someone will definitely have an answer for you
Ooh... got it! I’ll give it a try tonight! Thanks @lee.justin.m !!!