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

Questions and answers regarding the use of eclipse environment as seen in Servoy Developer

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

Postby sergei.sheinin » Sun Feb 22, 2015 6:33 am

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.
Attachments
eclipseWarning.png
eclipseWarning.png (11.95 KiB) Viewed 1183 times
Sergei Sheinin
JavaScript, RDBMS
http://js2dx.com
sergei.sheinin
 
Posts: 79
Joined: Wed May 07, 2014 3:22 pm

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

Postby jcompagner » Thu May 21, 2015 10:26 am

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.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7977
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

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

Postby pbakker » Thu May 21, 2015 10:52 am

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
pbakker
 
Posts: 2820
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

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

Postby japink.m » Thu May 21, 2015 9:22 pm

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?
japink.m
 
Posts: 20
Joined: Fri Jun 14, 2013 9:13 pm

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

Postby pbakker » Thu May 21, 2015 10:08 pm

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.
}
pbakker
 
Posts: 2820
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

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

Postby japink.m » Fri May 22, 2015 11:51 am

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 925 times
japink.m
 
Posts: 20
Joined: Fri Jun 14, 2013 9:13 pm

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

Postby pbakker » Fri May 22, 2015 8:02 pm

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.
pbakker
 
Posts: 2820
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands


Return to Eclipse Environment

Who is online

Users browsing this forum: No registered users and 2 guests