In my "other" projects I always assign an initial value to these properties.

Closure is OK with empty strings and -1 (or whatever) for numbers.

For complex types you will have to take into account that the type
annotation must match the initial value, e.g. if you want null to be
the initial value, the type must allow that, so that would be
{?Object} - where the question mark indicates that a null value is
allowed.

EdB



On Mon, Jan 27, 2014 at 8:36 PM, Alex Harui <[email protected]> wrote:
> I just tried to clean up some of the JSHint warnings in the JS code we've
> written for FlexJS.  The first thing I ran into was the way we declare
> uninitialized variables.  An example is:
>
> /**
>  * @expose
>  * @type {string}
>  */
> org.apache.flex.binding.BindingBase.prototype.sourceID;
>
> The closure linter is ok with this, but JSHint complains, expecting an "="
> and an initial value.  I can't find any documentation on what Closure says
> is the right thing to do with uninitialized variables.  So, what should we
> do?  Should we simply assign null or undefined?
>
>
> -Alex
>
>



-- 
Ix Multimedia Software

Jan Luykenstraat 27
3521 VB Utrecht

T. 06-51952295
I. www.ixsoftware.nl

Reply via email to