Skip to content

Commit

Permalink
* check base type when checking externs
Browse files Browse the repository at this point in the history
* add CLJS-3408 test, verifying reported issue is resolved
  • Loading branch information
swannodette committed Dec 5, 2023
1 parent 78f59f3 commit 253501d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/clojure/cljs/analyzer.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,10 @@
xmeta (meta x')]
(if (and (= 'Function (:tag xmeta)) (:ctor xmeta))
(or (has-extern?* (into '[prototype] (next pre)) externs' top)
(has-extern?* (next pre) externs' top))
(has-extern?* (next pre) externs' top)
;; check base type if it exists
(when-let [super (:super xmeta)]
(has-extern?* (into [super] (next pre)) externs top)))
(recur (next pre) externs' top))))))))

(defn has-extern?
Expand Down
11 changes: 11 additions & 0 deletions src/test/clojure/cljs/externs_infer_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,17 @@
["Object.renderInline;"])
res)))))

(deftest test-cljs-3408
(testing "inheritance of JS Types is inferred"
(let [ws (atom [])
res (infer-test-helper
{:forms '[(ns foo.core)
(.querySelectorAll js/document "div")]
:warnings ws
:warn true
:with-core? true})]
(is (empty? @ws)))))

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

0 comments on commit 253501d

Please sign in to comment.