Skip to content

Commit

Permalink
* externs: parse @extends into :super
Browse files Browse the repository at this point in the history
* add test case
  • Loading branch information
swannodette committed Dec 5, 2023
1 parent 0c5ecd7 commit 78f59f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/main/clojure/cljs/externs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@
{:tag (get-tag ty)}
(if (or (.isConstructor info) (.isInterface info))
(let [qname (symbol (.. node getFirstChild getQualifiedName))]
(cond-> {:tag 'Function}
(cond-> (merge {:tag 'Function}
(when (.hasBaseType info)
{:super (get-tag (.getBaseType info))}))
(.isConstructor info) (merge {:ctor qname})
(.isInterface info) (merge {:iface qname})))
(if (or (.hasReturnType info)
Expand Down
13 changes: 12 additions & 1 deletion src/test/clojure/cljs/externs_parsing_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
(:require [cljs.closure :as closure]
[cljs.externs :as externs]
[clojure.java.io :as io]
[clojure.test :as test :refer [deftest is]]))
[clojure.test :as test :refer [deftest is]])
(:import [com.google.javascript.jscomp CommandLineRunner]))

(deftest cljs-3121
(let [externs (externs/parse-externs
Expand All @@ -34,6 +35,16 @@
(is (= 'any (get-in ns [:defs 'get :ret-tag])))
(is (= 'array (get-in ns [:defs 'getKeys :ret-tag])))))

(deftest test-parse-super
(let [info (->
(filter
(fn [s]
(= "externs.zip//w3c_dom2.js" (.getName s)))
(CommandLineRunner/getDefaultExterns))
first externs/parse-externs externs/index-externs
(find 'HTMLDocument) first meta)]
(is (= 'Document (:super info)))))

(comment

(externs/parse-externs
Expand Down

0 comments on commit 78f59f3

Please sign in to comment.