I want to take advantage of visual studio intellisense therefore I have read:
http://msdn.microsoft.com/en-us/library/bb514138.aspx
Anyways why I do not get intellisense with:
function Customer() {
this.Id = 0;
this.FirstName = "";
this.LastName = "";
}
function Test() {
/// <returns type="Customer"></returns>
var c = new Object();
$.ajax({
async: false,
dataType: "json",
url: "Ajax/GetCustomer.aspx",
success: function (foundCustomer) {
// I know that found customer is of type Customer
c = foundCustomer;
}
});
return c;
}
var x = Test();
x. // No intellicense! why?
How can I tell visual studio know that the function is going to return an object of TYPE Customer
? For example if I replace the function Test for: function Test(){ return new Customer(); }
then intellicense will work.
Edit
My Goal at the end is to have something like:
function Customer() {
this.Id = 0;
this.FirstName = "";
this.LastName = "";
}
Object.prototype.CastToCustomer = function(){
/// <returns type="Customer"></returns>
return this;
}
$.ajax({
async: false,
dataType: "json",
url: "Ajax/GetCustomer.aspx",
success: function (foundCustomer) {
foundCustomer = foundCustomer.CastToCustomer();
foundCustomer.// Intellicense does not work :(
}
});
I get a lot of json objects and I will like to cast them using this helper functions.
Temporary solution:
This is what I ended up doing:
function Customer() {
this.Id = 0;
this.FirstName = "";
this.LastName = "";
}
$.ajax({
async: false,
dataType: "json",
url: "Ajax/GetCustomer.aspx",
success: function (foundCustomer) {
// this will never be true on real browser. It is always true in visual studio (visual studio will now think that found customer is of type Customer ;)
if (document.URL.length == 0) foundCustomer = new Customer();
foundCustomer.// Intellisense works!!!!
}
});