Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by

Currently we process the default externs and this collect type information for many standard JavaScript APIs. We could use this to understand cases like (.-length some-string) and infer that it will return a number. This one probably requires the Mike Files Clojure predicate inference work to be practical.

2 Answers

0 votes
by
_Comment made by: mfikes_

Predicate-induced inference has landed on master (CLJS-2866).

David has left a comment in the code showing how this might be leveraged: https://github.com/clojure/clojurescript/blob/f97d766defd02f7d43abd37e3e9b04790a521b1e/src/main/clojure/cljs/externs.clj#L165-L172

As an aside, this ticket may alleviate the need for explicit {{^string}} hints on {{subs}} (CLJS-2868).
0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-2987 (reported by dnolen)
...