Reputation: 6730
I'm having some issues (I think) with intellisense in my Win8 HTML5/JS app.
If I have the following code in a page (in the ready: function):
var control = element.querySelector("#rating").winControl;
My first question is, the .winControl property doesn't show in the intellisense, but from searching the web this appears to be the expected behaviour (given the difficulties in providing intellisense in a language like javascript)?
However, my main problem is now when I try to access properties on my control variable I get the message:
Intellisense was unable to determine an accurate completion list for this expression
I have added the /// <reference path...
etc to the base.js and ui.js in the WinJS reference but it still doesn't work.
Has anyone experienced this before? Is this the correct behaviour? What am I missing here?
Cheers
Upvotes: 3
Views: 843
Reputation: 1480
What you're seeing is the expected behavior in Visual Studio 2012. Currently .winControl does not show up even though it is valid at runtime.
As a workaround, you can use documentation comments to tell the JavaScript editor the type of the variable, and you can then get IntelliSense for it. Using your example above (I'll assume you want to see suggestions for the WinJS.UI.Rating control), type:
/// <var type="WinJS.UI.Rating"/>
var control = element.querySelector("#rating").winControl;
control.
And now you'll see the completion list for a Rating control.
Upvotes: 3
Reputation: 2305
The querySelector function returns a DOM element. Since .winControl is not a standard property on a DOM element, there is no way for intellisense to present it to you as an option.
Since your 'control' variable is being assigned to an object of a type that is unknown to intellisense, it is unable to give you any help on what properties may or may not be present on the unknown object.
Upvotes: 0