Questions

37 views
Skip to first unread message

Justin Grant

unread,
Mar 6, 2013, 8:46:04 AM3/6/13
to script...@googlegroups.com
Hi, I can't find this in the documentation or on the message boards, so it seemed good to post it...

We're currently using Google's Closure Library (we also use the Compiler, but that shouldn't affect our usage of Scripted).  First off, we include the library into our project statically at a later point.  Using our build process, we can just add it at a later point.  Is this something that can be pointed to within the Scripted?  We have a copy, so it's around, but not in a subdirectory of the project.  I read some things about how we can use JSLint directives to indicate what objects we are using, but that isn't going to help for the google library, as it is a very large library and not incorporated into a single variable like jQuery (with the "$" variable).

Secondly, one of the the things that the library api includes is a "goog.provide", which will create a namespace based on the string passed in.  For example,

goog.provide("com.google.mynamespace")

would immediately create the object com, containing the object google, containing the object mynamespace, and then you can modify that object's internals/prototype.  This is very useful in scoping large projects (please note that this tends to be culled at a later point by the Compiler, so I hope not to get a bunch of "that's bad practice"/expensive/etc comments.)

This seems to be causing issues in the Scripted editor as well, with every defined namespace getting the lovely red squiggly underline.  Is this something that can be accounted for when working with the editor?

Thanks,
Justin

Kris De Volder

unread,
Mar 6, 2013, 3:58:10 PM3/6/13
to script...@googlegroups.com
> Is this something that can be pointed to within the Scripted?

Not at the moment. Though it seems we need to solve that problem somehow. Too many people do things like you describe so that library code in the filesystem that you are using to edit your code on doesn't look precisely like what gets deployed.
There's already an issue on the issue tracker that, if we implemented it, maybe could address that problem (add your thoughts/vote to the issue about whether this would help or not).

 https://github.com/scripted-editor/scripted/issues/145


> Secondly, one of the the things that the library api includes is a "goog.provide", which will create a namespace
...

> This seems to be causing issues in the Scripted editor as well, with every defined namespace getting the lovely red squiggly underline.

This is expected. Scripted doesn't really know and has no good way of knowing that that particular library-call will define globals.


> Is this something that can be accounted for when working with the editor?

The only thing I can suggest right now is that you can tell jshint that 'com' is defined as a global.
You could add it to each file that uses the 'com' namespace in a /*global*/ comment, or you can add it for
all of your project at once in a jshint config file or in the .scripted file in your project.

Kris

Justin Grant

unread,
Mar 6, 2013, 9:02:58 PM3/6/13
to script...@googlegroups.com
Thanks.  Answered my bumbled question perfectly :)  I made a quick note on the issue so as to follow it an bring my specific use case (which I don't think is rare, based on the companies I've worked with).  Thanks for the help!

- Justin
Reply all
Reply to author
Forward
0 new messages