none
Visual Studio 2015 JavaScript Intellisense refuses to detect all properties set by the constructor.

    Question

  • Hi,

    I have this very frustrating problem with Visual Studio 2015 JavaScript Intellisense that refuses to detect all properties set by the constructor. I find this to be a very serious issue cause it multiplies with every class that I extend cause I do not see any properties defined and can't see them in any prototype function I define and this is just terrible to work with.

    Can anyone please help me figure out if it is an issue that I can fix with a VS configuration or something... or point me out where to report this major issue i am having? Thank you...

    this.app = this.app || {};

    (function () {
        "use strict";

        /**
        * @constructor
        */
        function Animal() {
            /** Is this animal alive? */
            this.alive = true;
            this.say = "rawr";

            this.addprops(); // intellisense finds it

            console.log(this.addedproperty); // intellisense finds it
        }

        var p = Animal.prototype;
        var s = Animal;

        p.testFailed = "test failed";

        p.testfunc = function () {
            console.log(Animal.TESTING); // intellisense finds it
            
            if (this.alive) { // intellisense does NOT find it
                console.log(this.say); // intellisense does NOT find it
            } else {
                console.log(this.testFailed); // intellisense finds it
            }

            console.log(this.addedproperty); // intellisense does NOT find it
        }

        p.addprops = function() {
            this.addedproperty = "addedproperty";
        }

        s.TESTING = "testing";

        app.Animal = Animal;
    }());





    • Edited by Filip Nedyalkov Friday, June 10, 2016 6:30 PM Forgot to add the first line of the code
    Friday, June 10, 2016 6:24 PM

Answers

All replies

  • Try a different approach:

    "use strict";

    var app = app || { };

    (function () { function Animal() { this.alive = true; this.say = "rawr"; this.addprops(); console.log(this.addedproperty); } Animal.prototype = { testFailed: "test failed", testfunc: function () { console.log(Animal.TESTING); if (this.alive) { console.log(this.say); } else { console.log(this.testFailed); } console.log(this.addedproperty); }, addprops: function () { this.addedproperty = "addedproperty"; } }; Animal.TESTING = "testing"; app.Animal = Animal; }());



    Saturday, June 11, 2016 6:44 AM
  • Great! You have found a workaround. Thank you for the reply at least it explains it.

    But isn't this stupid ? Why there is Intellisense when it can't figure out that the Animal.prototype is assigned to a variable ? Seriously - it figures out that I have a function where I add with code dynamic variables and functions which then I can call in my constructor and it finds them, but it cannot figure out that p = Animal.prototype ??? Well that's just very silly.

    Any idea where I can report this as bug ? Just incredible how modern IDEs can't do as simple things as this one...

    Saturday, June 11, 2016 1:14 PM
  • Hi Filip Nedyalkov,

    >>Any idea where I can report this as bug ? Just incredible how modern IDEs can't do as simple things as this one...

    You could report this problem to the Microsoft Connect feedback portal:

    http://connect.microsoft.com/

    Microsoft engineers will evaluate them. Also please share link here. I will help to vote it.

    Best Regards,

    Lake Xiao

    Monday, June 13, 2016 2:58 AM
    Moderator
  • Hi lake Xiao,

    thank you for the info, helped me a lot. Here is the link to the bug. Let me know if I didn't report it correct or something:

    https://connect.microsoft.com/VisualStudio/feedback/details/2809597

    Best regards,

    Filip Nedyalkov


    Monday, June 13, 2016 10:42 AM
  • Hi Filip Nedyalkov,

    I have voted it. And please mark your reply as the answer, so it would be helpful for other members who get the same issue as yours to research and find the report directly, and I could close this case.

    Have a nice day,

    Best Regards,

    Lake Xiao

    Tuesday, June 14, 2016 1:49 AM
    Moderator