We want to be able to use the following JSDoc info (or similar) on an Object parameter without all properties being required by the error checking mechanism in Developer:
- Code: Select all
* @param {{tMessage:String, tTo:String, tSubject:String;, aAttachments:Array<String>, tFrom:String, tCC:String, tBCC:String, dQueueEmail:Date}} emailProperties
Long version:
Ideally, we want to use a single parameter of type Object, and then supply properties as necessary. We can then handle properties that were not included with defaults, etc. Ideally, we could use the following (or similar):
- Code: Select all
/**
* @param {{tMessage:String, tTo:String, tSubject:String;, aAttachments:Array<String>, tFrom:String, tCC:String, tBCC:String, dQueueEmail:Date}} emailProperties
*/
function SendEmail(emailProperties)
{
// do stuff
}
The problem here, is that when we try to call this method without supplying all of the properties, we get a warning in Developer. I realize that it still functions, but I don't want to have thousands of these warnings spread throughout our solution, nor do I want to disable the error checking and go without the system keeping us honest (I know, I'm a dreamer). By doing the following, we are able to use this method without being forced to supply all of the potential properties the method might use.
- Code: Select all
* @param {Object} emailProperties
The problem with the above is that as we work in the code within the method, we get warnings on each reference to a properly telling us that it is not defined. We are also unable to benefit from the Intellisense as we code. I have read enough to see that a solution is to exclude the type in the JSDoc as follows:
- Code: Select all
* @param emailProperties
The problem with this is that there is no Intellisense or error checking. I'm aware that when you declare parameters, you can specify in the JSDoc that they are optional. However, I don't see how you can do this with the properties of an object. I'm also aware that we can suppress the warnings on each of the methods that call the method above...which would be nearly every method we write...no thanks. Does anyone have a solution to this?