cljsjs

2016-09-07T11:13:39.000140Z

Theres' a bug in react-datepicker externs. Where excludeDates is said to be a function but is in reality array(excludeDates: _react2.default.PropTypes.array,). Before discovering the bug I tried to just update the react-datepicker. But Im struggling, like so often with generating externs. So for this file https://www.refheap.com/122782/raw via http://michaelmclellan.me/javascript-externs-generator/ what name should I extern?

martinklepsch 2016-09-07T13:37:38.000141Z

@hlolli can't open your paste

2016-09-07T13:38:29.000142Z

ok, http://www.refheap.com is down seemingly

2016-09-07T13:39:13.000143Z

http://pastebin.com/raw/XmUQ0qgd

martinklepsch 2016-09-07T14:43:28.000144Z

@hlolli tried DatePicker?

martinklepsch 2016-09-07T14:43:48.000145Z

also looking in the console and just typing Date might yield other options

2016-09-07T14:45:20.000146Z

yes but not Date.

2016-09-07T14:48:38.000147Z

Date works, and returns only extern for the function Date. The last person to create externs for react-datepicker used DatePicker according to react-datepicker.ext.js So I must be doing something wrong.

martinklepsch 2016-09-07T14:55:08.000148Z

@hlolli what's the URL you're putting into the generator?

2016-09-07T14:59:37.000149Z

that raw pastebin I posted above. It's the generated js file from the jsx, but when I think about it, its the generated .js from the last cljsjs/react-datepicker. Maybe I run the project with node.js and get the newest .js file.

martinklepsch 2016-09-07T15:01:18.000150Z

You will need something that serves the file with a text/javascript content type otherwise it won't be loaded as JS

2016-09-07T15:03:35.000151Z

tried <http://localhost:8440/out/react-datepicker.inc.js> but the same. If it can extern the function Date, it must be able to read it correctly?

martinklepsch 2016-09-07T15:04:06.000152Z

Date is a JS constructor, are you sure it's coming from that file?

martinklepsch 2016-09-07T15:04:29.000153Z

open the console on the externs generator as well so you see if any issues occur

2016-09-07T15:05:28.000154Z

ok

2016-09-07T15:29:31.000156Z

Tried the node.js app for extern-generator, worked last time for me. I include all dependancies, index is react-onclickoutside. And still wont work.

generate-extern -f react.js, react-dom.js, index.js, moment.js, react-datepicker.inc.js -n DatePicker -o datep.ext.js

/usr/lib/node_modules/externs-generator/bin/extern:261
ma(sd,"exit").call(null,1));null==c&amp;&amp;(console.error("Please specify namespace to extern (e.g. -n jQuery)"),ma(sd,"exit").call(null,1));null==a&amp;&amp;(console.error("Please specify an output file for the extern (e.g. -o jquery-extern.js)"),ma(sd,"exit").call(null,1));for(var b=K(b),e=null,g=0,h=0;;)if(h&lt;g){var k=e.W(null,h);Mf(d,k);h+=1}else if(b=K(b))e=b,Cc(e)?(b=tb(e),h=ub(e),e=b,g=S(b),b=h):(b=M(e),Mf(d,b),b=O(e),e=null,g=0),h=0;else break;d=ma(d,c);if(null==d)throw[B("Namespace '"),B(c),B("' was not found. Make sure the library is loaded and the name is spelled correctly.")].join("");
                                                                                                                                                                                                                                                                                                                     
Namespace 'DatePicker' was not found. Make sure the library is loaded and the name is spelled correctly.

martinklepsch 2016-09-07T15:53:11.000161Z

@hlolli maybe open an issue and ping the people that previously created/updated the package

2016-09-07T15:58:56.000162Z

@therabidbanana (if its not inapproproate to ping you here), maybe you can look at the extern to react-datepicker you generated?

2016-09-07T16:00:36.000164Z

@hlolli : looking at the thread now

2016-09-07T16:04:53.000166Z

So are you just trying to update externs for current version?

2016-09-07T16:06:41.000167Z

I was trying that, to see if it solved the extern issue, that the externt wont say that excludeDates is a function, but an array. When using excludeDates on my datepicker component I encounter that error, telling me its not a function.

2016-09-07T16:08:24.000168Z

But I also have another bug unrelated to externs, hoping to see the library developers had fixed it (which is that the calander will disappear without giving onBlur or onFocus function call, but thats unrelated). (thats why Im curious to update react-datepicker to 0.29.0)

2016-09-07T16:14:25.000170Z

Not sure about the node externs-generator, haven't used that - it might not like the funky webpack wrappings from the react-datepicker build. It's entirely possible I missed a step with my notes - I had to try a few times to get the externs generator online to work

2016-09-07T16:17:22.000171Z

Yes I thought so too, that these webpack wrappings are causing the generator not finding the namespace functions. We could write this by hand, not that I know how to do that, but I would love to know how.

2016-09-07T16:18:23.000172Z

The full list of props for the datepicker is only ~25 functions/bools/arrays.

2016-09-07T16:20:45.000173Z

What errors are you seeing with the current externs?

2016-09-07T16:22:01.000174Z

react-datepicker.inc.js:454 Uncaught TypeError: excludeDates.some is not a function

2016-09-07T16:23:07.000175Z

What's the calling code look like that generates that?

2016-09-07T16:23:46.000176Z

Now like this, but its the same with js-obj and/or js-global-array :excludeDates [(js/moment)]

2016-09-07T16:26:00.000179Z

full code call tough

(js/React.createElement
                            js/DatePicker
                            #js {:showYearDropdown true
                                 :dateFormat "YYYY-MM-DD"
                                 :key "service-left"
                                 :id "service-from"
                                 :excludeDates [(js/moment)]
                                 :maxDate (js/moment)
                                 :placeholderText "Date from"
                                 :onChange (fn [t]
                                             (om/update-state! this assoc :service-from t)
                                             (om/update-state! this assoc :service-from-focus? false)
                                             (when (js/moment.isMoment (:service-to (om/get-state this)))
                                               (when (.isAfter t (:service-to (om/get-state this)))
                                                 (om/update-state! this assoc :service-to nil))))
                                 :onBlur #(om/update-state! this assoc :service-from-focus? false)
                                 :onFocus #(om/update-state! this assoc :service-from-focus? true)
                                 :selected (:service-from (om/get-state this))
                                 :title "Service date from"
                                 :fixedHeight true
                                 :isClearable true
                                 :popoverTargetOffset "18px 0"})

2016-09-07T16:28:25.000183Z

Seems like #js isn't working like you expect it to and downgrading the CLJS vector to a real JS array

2016-09-07T16:29:18.000185Z

I'd guess the bug isn't in the externs there

2016-09-07T16:29:57.000186Z

You need to put #js in front of nested objects

2016-09-07T16:30:03.000187Z

(or in your case, arrays)

2016-09-07T16:30:11.000188Z

excludeDates: #js [(js/moment)]

2016-09-07T16:30:49.000190Z

yes, ahhhh, I should have known that.

2016-09-07T16:31:39.000191Z

it works now 😄 so I leave the package update to someone else. Thanks for looking into this!

2016-09-07T16:32:00.000192Z

I think clj-&gt;js handles arbitrary nesting, you could try wrapping all your options in that as well.

2016-09-07T16:32:57.000195Z

yes I do it all the time with style. But I was recently using react-material-ui, and all arrays there didnt need the #js tag. But then I remembered that I was using a wrapped lib from madvas.

2016-09-07T16:32:59.000196Z

(If you want to avoid forgetting another #js - it's easy to do, I think I've had the issue a few times)

2016-09-07T16:34:21.000197Z

ok, wow, I thought clj->js was just the exact same of #js, glad to learn that my millions of nested #js tags can be removed. I type #js too often hehe.

2016-09-07T16:36:08.000198Z

I think technically they compile differently (and theoretically #js is more efficient in that case - because it's a macro instead of a function call?), but I haven't looked into the details

2016-09-07T16:37:19.000200Z

ok ok. Well, its enough work today. Now I go home and... yes, do more clojure 😄 so see you around

👋 1
mikebelanger 2016-09-07T19:57:53.000203Z

Hi guys I’m having a hard time making an externs package, I’m using this tool : http://michaelmclellan.me/javascript-externs-generator/ and I’m trying to get an empty object, ( _module ) and it says it can’t find it. The js file is here : https://github.com/TriumphLLC/Blend4Web/blob/master/src/b4w.js I’m not sure I understand how to use this tool.

juhoteperi 2016-09-07T19:59:17.000205Z

@mikebelanger what is an empty object?

mikebelanger 2016-09-07T19:59:50.000206Z

@juhoteperi ie var _module = {};

juhoteperi 2016-09-07T20:00:01.000207Z

But that is inside a closure: var b4w = ((typeof b4w === "object") ? b4w : (function(exports) {

mikebelanger 2016-09-07T20:00:59.000209Z

@juhoteperi oh so I should try and grab the b4w object instead?

juhoteperi 2016-09-07T20:01:05.000210Z

Yes

mikebelanger 2016-09-07T20:05:22.000211Z

@juhoteperi ok it’s saying it can’t find the b4w. All I entered is ‘b4w’, do I have to enter one of the object’s values?

juhoteperi 2016-09-07T20:07:05.000212Z

hmh, should work

mikebelanger 2016-09-07T20:07:58.000213Z

It looks the b4w.js file has some namespace declarations above that, would that interfere with it?

juhoteperi 2016-09-07T20:08:19.000214Z

I don't think it should be reading those JSDocs

juhoteperi 2016-09-07T20:08:29.000215Z

what url are you using for the generator?

juhoteperi 2016-09-07T20:09:17.000217Z

for the JS file

mikebelanger 2016-09-07T20:09:58.000218Z

https://github.com/TriumphLLC/Blend4Web/blob/master/src/b4w.js ..mind you this is under the git blob, maybe that’s the problem

juhoteperi 2016-09-07T20:10:14.000219Z

yes, it can load a html file

juhoteperi 2016-09-07T20:10:20.000220Z

check browser console for errors

juhoteperi 2016-09-07T20:12:16.000221Z

If it is hard to find proper copy available at http server, you can download the file to local disk and use this npm tool: https://github.com/jmmk/javascript-externs-generator (npm install -g externs-generator)

juhoteperi 2016-09-07T20:12:39.000223Z

(In fact that is the same generator but as a npm package)

mikebelanger 2016-09-07T20:14:11.000224Z

Are you sure it can handle html? The console is complaining about the ‘<!DOCTYPE html>’ right at the beginning

juhoteperi 2016-09-07T20:14:26.000225Z

ah sorry, typo 😄

juhoteperi 2016-09-07T20:14:36.000226Z

I meant to say, it can't load a html file

mikebelanger 2016-09-07T20:14:52.000227Z

@juhoteperi it’s saying "SyntaxError: expected expression, got ‘<'"

mikebelanger 2016-09-07T20:15:08.000228Z

Oh, sorry just read your last message 😛

mikebelanger 2016-09-07T20:16:19.000229Z

@juhoteperi cool it works when I goto original git path, thanks!