File tree Expand file tree Collapse file tree 1 file changed +32
-2
lines changed
Expand file tree Collapse file tree 1 file changed +32
-2
lines changed Original file line number Diff line number Diff line change 475475 (emits " (function(){throw " throw " })()" )
476476 (emitln " throw " throw " ;" )))
477477
478- (defn resolve-type [env t]
479- (str (:name (ana/resolve-var env (symbol t)))))
478+ (def base-types
479+ #{" boolean" " Boolean"
480+ " string" " String"
481+ " number" " Number"
482+ " array" " Array"
483+ " object" " Object"
484+ " RegExp"
485+ " Date" })
486+
487+ (defn resolve-type [env ^String t]
488+ (cond
489+ (get base-types t) t
490+
491+ #?(:clj (.startsWith t " !" )
492+ :cljs (gstring/startsWith t " !" )) t
493+
494+ #?(:clj (.startsWith t " {" )
495+ :cljs (gstring/startsWith t " {" )) t
496+
497+ #?(:clj (.startsWith t " function" )
498+ :cljs (gstring/startsWith t " function" )) t
499+
500+ :else
501+ (let [optional? #?(:clj (.endsWith t " =" )
502+ :cljs (gstring/endsWith t " =" ))
503+ t (if optional?
504+ (subs t 0 (dec (count t)))
505+ t)
506+ ret (str (:name (ana/resolve-var env (symbol t))))]
507+ (if optional?
508+ (str ret " =" )
509+ ret))))
480510
481511(defn resolve-types [env ts]
482512 (let [ts (-> ts string/trim (subs 1 (dec (count ts))))
You can’t perform that action at this time.
0 commit comments