File tree 4 files changed +30
-3
lines changed
4 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 1048
1048
xmeta (meta x')]
1049
1049
(if (and (= 'Function (:tag xmeta)) (:ctor xmeta))
1050
1050
(or (has-extern?* (into '[prototype] (next pre)) externs' top)
1051
- (has-extern?* (next pre) externs' top))
1051
+ (has-extern?* (next pre) externs' top)
1052
+ ; ; check base type if it exists
1053
+ (when-let [super (:super xmeta)]
1054
+ (has-extern?* (into [super] (next pre)) externs top)))
1052
1055
(recur (next pre) externs' top))))))))
1053
1056
1054
1057
(defn has-extern?
Original file line number Diff line number Diff line change 73
73
{:tag (get-tag ty)}
74
74
(if (or (.isConstructor info) (.isInterface info))
75
75
(let [qname (symbol (.. node getFirstChild getQualifiedName))]
76
- (cond-> {:tag 'Function}
76
+ (cond-> (merge {:tag 'Function}
77
+ (when (.hasBaseType info)
78
+ {:super (get-tag (.getBaseType info))}))
77
79
(.isConstructor info) (merge {:ctor qname})
78
80
(.isInterface info) (merge {:iface qname})))
79
81
(if (or (.hasReturnType info)
Original file line number Diff line number Diff line change 475
475
[" Object.renderInline;" ])
476
476
res)))))
477
477
478
+ (deftest test-cljs-3408
479
+ (testing " inheritance of JS Types is inferred"
480
+ (let [ws (atom [])
481
+ res (infer-test-helper
482
+ {:forms '[(ns foo.core )
483
+ (.querySelectorAll js/document " div" )]
484
+ :warnings ws
485
+ :warn true
486
+ :with-core? true })]
487
+ (is (empty? @ws)))))
488
+
478
489
(comment
479
490
(binding [ana/*cljs-ns* ana/*cljs-ns*]
480
491
(ana/no-warn
Original file line number Diff line number Diff line change 10
10
(:require [cljs.closure :as closure]
11
11
[cljs.externs :as externs]
12
12
[clojure.java.io :as io]
13
- [clojure.test :as test :refer [deftest is]]))
13
+ [clojure.test :as test :refer [deftest is]])
14
+ (:import [com.google.javascript.jscomp CommandLineRunner]))
14
15
15
16
(deftest cljs-3121
16
17
(let [externs (externs/parse-externs
34
35
(is (= 'any (get-in ns [:defs 'get :ret-tag ])))
35
36
(is (= 'array (get-in ns [:defs 'getKeys :ret-tag ])))))
36
37
38
+ (deftest test-parse-super
39
+ (let [info (->
40
+ (filter
41
+ (fn [s]
42
+ (= " externs.zip//w3c_dom2.js" (.getName s)))
43
+ (CommandLineRunner/getDefaultExterns ))
44
+ first externs/parse-externs externs/index-externs
45
+ (find 'HTMLDocument) first meta)]
46
+ (is (= 'Document (:super info)))))
47
+
37
48
(comment
38
49
39
50
(externs/parse-externs
You can’t perform that action at this time.
0 commit comments