Page 1 of 1

"- The property <...> is undefined in javascript" warning

PostPosted: Sun Feb 22, 2015 6:33 am
by sergei.sheinin
I encountered this strange warning in JavaScript while coding a prototype of an object. The warning message is in the attachment. Please note that removing top reference to "this" scope variable removes the warning. My workaround was to set "this" scope variables (y and z in the example) to local variables in "var" declaration at the top of the function.

Re: "- The property <...> is undefined in javascript" warnin

PostPosted: Thu May 21, 2015 10:26 am
by jcompagner
yes i think the code parser doesn't fully work with those kind of object constructs and then the usage of the "this" in a function of such an object.

Re: "- The property <...> is undefined in javascript" warnin

PostPosted: Thu May 21, 2015 10:52 am
by pbakker
Have a look at the @this JSDoc annotation with which you can specify the type of 'this'

Not ideal to have to type it using JSDoc, but at least it works.

Paul

Re: "- The property <...> is undefined in javascript" warnin

PostPosted: Thu May 21, 2015 9:22 pm
by japink.m
Already any progess on @this matter?

I want to properly JSDoc type several constructors like the following:
/**
* @type{{sKey:String, aForm:Array, sMethod:String, aArguments:Array}} oSHORTCUT
* @properties={typeid:35,uuid:"ADA39EDF-12AD-4DD0-8EB2-1B5B199E44CF",variableType:-4}
*/
var oSHORTCUT = function(){
this.sKey = '';
this.aForm = [];
this.sMethod = '';
this.aArguments = [];
};

The @type declaration isn't working of course. I have been playing around with @this and @constructor. Even tried @class, @property although Servoy doesn't seem to know these types.
Can anybody tell me how to do this? And can somebody please point me to JSdoc documentation which is understandable, even for me?

Re: "- The property <...> is undefined in javascript" warnin

PostPosted: Thu May 21, 2015 10:08 pm
by pbakker
Don't see how your question is related to @this, but anyway: what is not woring in this code for you?
Code: Select all
/**
* @constructor
* @properties={typeid:35,uuid:"ADA39EDF-12AD-4DD0-8EB2-1B5B199E44CF",variableType:-4}
*/
var oSHORTCUT = function(){
   this.sKey = '';
   this.aForm = [];
   this.sMethod = '';
   this.aArguments = [];
};

function test() {
   var x = new oSHORTCUT()
   x.
}

Re: "- The property <...> is undefined in javascript" warnin

PostPosted: Fri May 22, 2015 11:51 am
by japink.m
The object properties don't get a type declaration. I thought with @this I could give every property a type declaration. So when you create a new shortcut object out of the constructor you want to show the user the inteded types as is the keys with other properties an methods, see picture.

Shortcut_instantiation.png
Shortcut_instantiation.png (21.2 KiB) Viewed 7041 times

Re: "- The property <...> is undefined in javascript" warnin

PostPosted: Fri May 22, 2015 8:02 pm
by pbakker
I think Servoy knows the types just fine, it is just that it is not displaying them in the code completion popup.

Probably if you provide JSDoc comments with an @type annotation for each property the types will start to show up, but I think Servoy should show those automatically. Best to file a case for that.