Fork me on GitHub
#cljs-dev
<
2017-04-30
>
cgrand06:04:43

@nikki that the evaluated user code can take over input and output stream. (A bIt like a subshell) See the 1st message of Rich Hickey in this discussion https://groups.google.com/forum/m/#!topic/clojure-dev/Dl3Stw5iRVA

thheller09:04:16

(ns demo.foreign)

(js/console.log (js/foo))

thheller10:04:11

(ns demo.foreign)

(defn ^:export foo [x]
  (.helloWorld x))

thheller10:04:20

CLOSURE-WARNING: demo/foreign.cljs[4:15] (compiled to demo/foreign.js[4:9])
	Property helloWorld never defined on x

thheller10:04:37

now only need to get rid of the bajillion other warnings 😞

thheller13:04:51

CLOSURE-WARNING: cljs/core.cljs[293:4] (compiled to cljs/core.js[325:12])
	Property nodeGlobalRequire never defined on goog


CLOSURE-WARNING: cljs/core.cljs[364:18] (compiled to cljs/core.js[349:11])
	variable process is undeclared


CLOSURE-WARNING: cljs/core.cljs[365:14] (compiled to cljs/core.js[349:51])
	Property hrtime never defined on process


CLOSURE-WARNING: cljs/core.cljs[366:21] (compiled to cljs/core.js[350:16])
	Property hrtime never defined on process


CLOSURE-WARNING: cljs/core.cljs[10487:40] (compiled to cljs/core.js[35318:17])
	Property number never defined on Error


CLOSURE-WARNING: cljs/core.cljs[10490:52] (compiled to cljs/core.js[35324:23])
	Property columnNumber never defined on Error


CLOSURE-WARNING: cljs/core.cljs[10749:32] (compiled to cljs/core.js[35800:35])
	variable global is undeclared


CLOSURE-WARNING: demo/foreign.cljs[4:15] (compiled to demo/foreign.js[4:9])
	Property helloWorld never defined on x

thheller13:04:11

can we maybe move the self-host/node only things out of cljs.core?

thheller13:04:20

I could just include externs for those always but that seems dirty

thheller13:04:49

the goal here is to warn at compile time when externs are missing. not at runtime.

thheller15:04:27

@dnolen I know you said :check-types probably isn't a goal anymore but I have it working. just requires CLJS-2019 and https://github.com/thheller/shadow-build/blob/c09258cad22707a3e1c5aaf703cdba661fed8a6d/src/main/shadow/cljs/build.clj#L2434-L2485

thheller15:04:50

CLOSURE-WARNING: cljs/core/async/impl/buffers.cljs[23:0] (compiled to cljs/core/async/impl/buffers.js[21:16])
	Bad type annotation. Unknown type cljs.core.async.impl.buffers.Object


CLOSURE-WARNING: cljs/core/async/impl/timers.cljs[59:0] (compiled to cljs/core/async/impl/timers.js[248:16])
	Bad type annotation. Unknown type cljs.core.async.impl.timers.Object

thheller15:04:08

it keeps finding actual problems so I think it is very worth it

thheller15:04:54

CLOSURE-WARNING: smartchecker/user.cljs[249:31] (compiled to smartchecker/user.js[573:7])
	Function parseInt: called with 1 argument(s). Function requires at least 2 argument(s) and no more than 2 argument(s).

thheller15:04:52

registering the CLJS protocol properties with the type registry seems like a hack but it seems to do the trick

thheller16:04:29

and it seems to produce very nice accurate warnings for missing externs (with any :infer-externs support)

dnolen16:04:04

@thheller ok, will take a look later this week