3

In an MVC 4 ASP.Net project I have the following JavaScript file:

Foo = function () {
    ///<field name="bar" type="Foo" mayBeNull="true"></field>
    this.bar = null;
}

Foo.prototype.test = function () {
    this.
}

When I type the period in test(), I get no intellisense support ("intellisense was unable to determine an accurate completion list for this expression").

If I remove the line this.bar = null;, I get full intellisense support, but bar has not been initialized to null.

If I instead change the comment's type to another type, e.g. to Number or to another declared constructor method, I get full intellisense support for that type.

If I change the initialization to this.bar = 6;, I get intellisense support for Number which seems reasonable.

The problem seems to be that intellisense is not able to match null to the Foo class, but only in the constructor method of the specified type.

Is there a way I can get intellisense to work with the null-initialization?

If I try out intellisense at the end of the constructor method, I get the following result:

The original variant gives me intellisense for this, but the type of bar is unknown.

If I remove this.bar = null;, intellisense tells me that the type of bar is Foo, but is unable to get its members.

If I change the initialization to this.bar = 6;, I get intellisense support for Number.

Update

Bug report has been filed at Microsoft Connect. If you can reproduce the problem, feel free to let them know.

4
  • Try swapping those two lines (maybe) Commented Jun 11, 2014 at 21:20
  • maybe var n = null .... this.bar = n; Commented Jun 11, 2014 at 21:22
  • @SLaks This does not break intellisense completely anymore, but bar's type is unknown. Btw, I have found out that the <field> declaration should be before any code. Not before the actual field declaration as specified in the documentation. Commented Jun 11, 2014 at 21:23
  • @rafaelcastrocouto No, same behavior. Commented Jun 11, 2014 at 21:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.