Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new succeeds, dot notation fails for JS class in sci env #862

Closed
sritchie opened this issue Dec 26, 2022 · 3 comments
Closed

new succeeds, dot notation fails for JS class in sci env #862

sritchie opened this issue Dec 26, 2022 · 3 comments

Comments

@sritchie
Copy link
Contributor

version

0.6.37

platform

JVM

problem

I found this maybe-bug with SCI via Clerk…

I built custom JS with this namespace:

(ns mathbox.clerk-ui
  (:require ["three" :as three]
            [nextjournal.clerk.sci-env]
            [sci.ctx-store]
            [sci.core :as sci]))

(def three-ns
  (-> (into {}
            (map (fn [[k v]] [(symbol k) v]))
            (.entries js/Object three))))

(sci.ctx-store/swap-ctx!
 sci/merge-opts
 {:namespaces  {'three three-ns}})

then, in my clerk viewer, I can call constructors with the new keyword:

(js/console.log (new three/Color 0xff4136))

and I see

image

but if I call (three/Color. 0xff4136) instead (ie with dot notation) I get

image

@borkdude
Copy link
Collaborator

borkdude commented Dec 26, 2022

Thanks, appreciate the report! It would save me time if you can make isolated repros without project specific config, like this:

(sci/eval-string "(new foo/String nil)" {:namespaces {'foo {'String js/String}}})
#object[String null]

vs:

cljs.user=> (sci/eval-string "(foo/String. nil)" {:namespaces {'foo {'String js/String}}})
Execution error (ExceptionInfo) at (<cljs repl>:1).
Could not resolve symbol: String

@sritchie
Copy link
Contributor Author

Yes, thank you for the nudge here, I will do this going forward! (Assuming that what you have here is enough repro for this issue, I can do more if not).

@borkdude
Copy link
Collaborator

Yes, this is sufficient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants