Skip to content

Commit 8b32c51

Browse files
author
dnolen
committed
return type extern inference appears to work
1 parent 342923b commit 8b32c51

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

src/test/clojure/cljs/analyzer_tests.clj

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -642,22 +642,32 @@
642642
(map (comp :externs second)
643643
(get @test-cenv ::a/namespaces))))))
644644

645+
(->
646+
(find (externs/externs-map
647+
(closure/load-externs
648+
{:externs ["src/test/externs/test.js"]
649+
:use-only-custom-externs true}))
650+
'baz)
651+
first meta)
652+
645653
;; User supplied externs
646654
(let [test-cenv (atom {::a/externs (externs/externs-map
647655
(closure/load-externs
648-
{:externs ["src/test/externs/test.js"]
649-
:use-only-custom-externs true}))})]
656+
{:externs ["src/test/externs/test.js"]}))})]
650657
(binding [a/*cljs-ns* a/*cljs-ns*
651658
a/*cljs-warnings* (assoc a/*cljs-warnings* :infer-warning true)]
652659
(e/with-compiler-env test-cenv
653660
(a/analyze-form-seq
654661
'[(ns foo.core)
655-
(defn bar [^js/Foo a]
662+
(defn baz [^js/Foo a]
656663
(.wozMethod a)
657-
(.gozMethod a))]))
664+
(.gozMethod a))
665+
(js/console.log (.wozMethod (js/Foo.)))
666+
(js/console.log (.wozMethod (js/baz)))]))
658667
(cc/emit-externs
659668
(reduce util/map-merge {}
660669
(map (comp :externs second)
661670
(get @test-cenv ::a/namespaces))))))
662671

672+
663673
)

src/test/externs/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/*
2-
@constructor
1+
/**
2+
* @constructor
33
*/
44
var Foo = function() {};
55
Foo.prototype.wozMethod = function() {
66
};
77

88
/**
9-
@return {Foo}
9+
* @return {Foo}
1010
*/
11-
baz = function() {};
11+
var baz = function() {};

0 commit comments

Comments
 (0)