Skip to content

Commit f97d766

Browse files
author
dnolen
committed
example of externs parsing to get ns information and type info from
a Closure lib
1 parent 1d1cee6 commit f97d766

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

src/main/clojure/cljs/externs.clj

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
(ns cljs.externs
1010
(:require [clojure.string :as string]
11-
[cljs.util :as util])
11+
[cljs.util :as util]
12+
[clojure.java.io :as io]
13+
[cljs.js-deps :as js-deps])
1214
(:import [java.util.logging Level]
1315
[com.google.javascript.jscomp
1416
CompilerOptions SourceFile JsAst CommandLineRunner]
@@ -153,6 +155,27 @@
153155
defaults sources))))
154156

155157
(comment
158+
(require '[clojure.java.io :as io]
159+
'[cljs.closure :as closure]
160+
'[clojure.pprint :refer [pprint]]
161+
'[cljs.js-deps :as js-deps])
162+
163+
(get (js-deps/js-dependency-index {}) "goog.string")
164+
165+
;; {:tag Function :ret-tag boolean}
166+
(->
167+
(nth
168+
(parse-externs
169+
(closure/js-source-file "goog/string/string.js"
170+
(io/input-stream (io/resource "goog/string/string.js"))))
171+
2)
172+
last meta)
173+
174+
(externs-map
175+
[(closure/js-source-file "goog/string/string.js"
176+
(io/input-stream (io/resource "goog/string/string.js")))]
177+
{})
178+
156179
(externs-map)
157180

158181
(-> (externs-map)

0 commit comments

Comments
 (0)