Warning about extending an existing JS type

it’s funny that if I haven’t written a question in a while, I feel a certain resistance . I admire those who can ask questions freely; I can fall into being a bit sheepish; it is out of a respect I hold for the Clojure community, and I just don’t want to waste anybody’s time . with this one, I suspect it’s something really simple

I’m creating a very simple web app with Helix . at this point it is simple enough that I can paste the code in its entirety: behold core.cljs:

(ns app.core
  (:require
   [helix.core :refer [defnc $]]
   [helix.dom :as d]
   ["react-dom/client" :refer [createRoot]]))

(defnc app []
  (d/h1 "The Morning Red"))

(defonce root
  (createRoot (.getElementById js/document "root")))

(defn mount-root []
  (.render root ($ app)))

(defn start []
  (mount-root))

I’m using shadow-cljs . when I go shadow-cljs watch app, as one does, I get this:

[:app] Compiling ...
[:app] Build completed. (133 files, 132 compiled, 1 warnings, 7.87s)

------ WARNING #1 - :extending-base-js-type ------------------------------------
 Resource: helix/core.cljs:12:3
--------------------------------------------------------------------------------
   9 | 
  10 | 
  11 | (when (exists? js/Symbol)
  12 |   (extend-protocol IPrintWithWriter
---------^----------------------------------------------------------------------
 Extending an existing JavaScript type - use a different symbol name instead of js/Symbol e.g symbol
--------------------------------------------------------------------------------
  13 |     js/Symbol
  14 |     (-pr-writer [sym writer _]
  15 |       (-write writer (str "\"" (.toString sym) "\"")))))
  16 | 
--------------------------------------------------------------------------------

now, it’s ‘just’ a warning . but I don’t like warnings . any advice? . perhaps the solution is to turn off the warning — so I’d appreciate to know how to do that

thanks for your time . you’re a wonderful bunch, and I’m proud to consider myself a Clojure programmer

It is just a warning, you can ignore it for now.

It only became an issue due to a change in the most recent CLJS release. It was adressed in helix, but as far as I can tell no new version was released yet.

Turning it off is not recommended, you shouldn’t see it again on recompiles. If you still rather get rid of it you can set :compiler-options {:warnings {:extending-base-js-type false}}.

PS: There is absolutely nothing wrong with asking questions. See Newest Questions - Stack Overflow. People ask a lot of questions. :slight_smile:

2 Likes

Just to address this point a bit more. People here and in other Clojure communities are there voluntarily, and those who answer do so because they want to help. If there were no questions, they wouldn’t be able to take joy in answering them. :slight_smile:

5 Likes