Skip to content

Commit 0ca217d

Browse files
committed
munge @param in emitted comment so Closure type checking works
with ClojureScript idiomatic names
1 parent a741cd4 commit 0ca217d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main/clojure/cljs/compiler.cljc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,25 @@
475475
(emits "(function(){throw " throw "})()")
476476
(emitln "throw " throw ";")))
477477

478+
(defn munge-param [line]
479+
(if (re-find #"@param" line)
480+
(let [[p t n & xs] (map string/trim
481+
(string/split (string/trim line) #" "))]
482+
(if (and (= "@param" p)
483+
t #?(:clj (.startsWith ^String t "{")
484+
:cljs (gstring/startsWith t "{")))
485+
(string/join " " (concat [p t (munge n)] xs))
486+
line))
487+
line))
488+
478489
(defn emit-comment
479490
"Emit a nicely formatted comment string."
480491
[doc jsdoc]
481492
(let [docs (when doc [doc])
482493
docs (if jsdoc (concat docs jsdoc) docs)
483494
docs (remove nil? docs)]
484495
(letfn [(print-comment-lines [e]
485-
(let [[x & ys] (string/split-lines e)]
496+
(let [[x & ys] (map munge-param (string/split-lines e))]
486497
(emitln " * " (string/replace x "*/" "* /"))
487498
(doseq [next-line ys]
488499
(emitln " * "

0 commit comments

Comments
 (0)