Skip to content

Commit

Permalink
* add info helper
Browse files Browse the repository at this point in the history
* add filter-externs helper
* eval comments
  - the problem is complex type expressions
  • Loading branch information
swannodette committed Mar 1, 2025
1 parent fc8522e commit f3bb007
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/clojure/cljs/externs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,24 @@
(parse-externs (resource->source-file rsrc))
(:module desc))}))))

(defn info
"Helper for grabbing var info from an externs map.
Example:
(info externs '[Number isNaN])
See `externs-map`"
[externs props]
(-> externs
(get-in (butlast props))
(find (last props))
first meta))

(defn filtered-externs [f]
(->>
(filter
#(= f (.getName %))
(default-externs))
first parse-externs index-externs))

(comment
(require '[clojure.java.io :as io]
'[cljs.closure :as closure]
Expand Down
15 changes: 15 additions & 0 deletions src/test/clojure/cljs/externs_infer_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,21 @@
:with-core? true})]
(is (empty? @ws)))))

(comment

(externs/info
(::ana/externs @(env/default-compiler-env))
'[console])

(externs/info
(::ana/externs @(env/default-compiler-env))
'[crypto])

(-> (externs/filtered-externs "externs.zip//w3c_webcrypto.js")
(externs/info '[crypto]))

)

(comment
(binding [ana/*cljs-ns* ana/*cljs-ns*]
(ana/no-warn
Expand Down

0 comments on commit f3bb007

Please sign in to comment.