ClojureScript now infers function return types, propagating this information to call sites.

Consider these predicates:

(defn finite? [x] (not (infinite? x))) (defn big? [x] (and (pos? x) (finite? x)))

Previously, code like the following

(if (big? 11) "hi" "bye")

would emit defensive JavaScript that coerces the return value of big? to a Boolean by using cljs.core.truth_ :

(cljs.core.truth_(cljs.user.big_QMARK_.call(null,(11)))?"hi":"bye")

Now, the compiler instead infers that finite? always returns a Boolean value, and therefore so does big? , and emits more efficient code:

((cljs.user.big_QMARK_.call(null,(11)))?"hi":"bye")

With inference like this, it is no longer necessary to manually add a ^boolean type hint to a predicate used in performance-critical code, so long as the return value can be infered from the predicate function body.

In general, any inferred types will automatically flow from function bodies outward, such as an inferred numeric type in the following example:

(defn foo [x] (+ x 3))

If foo is used in a context where types are checked, as in

(+ (foo 1) "a")

you will now see a warning that properly reflects the type:

WARNING: cljs.core/+, all arguments must be numbers, got [number string] instead