TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Private members appearing in intellisense outside of the class

Open Anupheaus opened this issue 12 years ago • 12 comments

I don't know if this is by design but outside of the class I am able to see private static members, which I don't believe I should be able to, for example:

I have a class named "NotifyChanged" (in the "Aspect" module/namespace) and it inherits from "Base" (also in the "Aspect" module/namespace). Base has a private static method named "createGet" which is only used within the Base class. In a completely different class in a completely different module/namespace I am able to type "Aspect.NotifyChanged.cre" and the intellisense pops up with createGet. If I continue, the IDE then underlines the whole line saying that createGet is a private method and is not accessible - but it still displays it as an method to call in intellisense?

Please also see attached screenshots. tsissue_1 image

Anupheaus avatar Nov 21 '14 13:11 Anupheaus

Can you share the code or some reduced repro? A naive attempt to model what you're describing doesn't show the private showing up when it shouldn't.

danquirk avatar Nov 21 '14 18:11 danquirk

To reproduce:

  1. Create a new project (I created a console application).
  2. Add a new typescript file.
  3. Copy and paste the following:
module BaseModule {

    export class BaseClass {

        private static PrivateMethod() {
            return '';
        }

    }

}

module DerivedModule {
    export class DerivedClass extends BaseModule.BaseClass {
    }
}

DerivedModule.DerivedClass

When you type the period (.) at the end of DerivedClass, my intellisense shows the private method:

image

Anupheaus avatar Nov 23 '14 14:11 Anupheaus

Additional info: TypeScript v1.3, Visual Studio 2013 (update 3 currently).

Anupheaus avatar Nov 23 '14 14:11 Anupheaus

Since I have only recently updated to TypeScript v1.3 I didn't realise but it is actually showing me all private variables when I thought it was only private static ones. This sounds like it is more an issue with my setup of Visual Studio and perhaps I should repair something or update it to the latest version (update 4).

Anupheaus avatar Nov 24 '14 10:11 Anupheaus

After having updated Visual Studio to update 4, only static private members are still being shown within intellisense now (all types; variables, properties and methods).

Anupheaus avatar Nov 24 '14 12:11 Anupheaus

Strange. With VS2013 Update 4 and VS2015 your repro behaves as expected with no privates (static or otherwise) shown outside the class. The invalid uses are generating compiler errors despite this?

danquirk avatar Nov 24 '14 20:11 danquirk

Yes the compiler is generating errors when I select any from the intellisense window.

This is very strange, now i'm seeing private non-static members again in certain circumstances :(

Can you think of anything for me to try as some of my intellisense popups are getting rather large and with my private variables all starting with a _ they are appearing at the top of the popup.

See below (I know it is not a valid use case because it is expecting an instance of Test1Class not an anonymous object but it shows another instance of where intellisense just isn't working correctly): image

Interestingly, if I create an new instance of Test1Class directly and access it, it works fine: image

Any ideas please?

Anupheaus avatar Nov 26 '14 09:11 Anupheaus

How to attach a file here? I can add a reproduction of the bug.

ghost avatar Nov 26 '14 19:11 ghost

Posting it to a gist is the easiest way

RyanCavanaugh avatar Nov 26 '14 19:11 RyanCavanaugh

You can take it here https://github.com/BBGONE/jRIAppTS/blob/generics/BUGDEMO/BUGDEMO.zip?raw=true

i added it to my project on github in order to share

ghost avatar Nov 26 '14 19:11 ghost

Thanks!

RyanCavanaugh avatar Nov 26 '14 19:11 RyanCavanaugh

I've tried to reproduce this issue using typescriptServices.js build from the master and VS2013 Update 3 - no luck. I'm closing this bug for now, feel free to reopen in if you still see it in the latest bits.

vladima avatar Dec 04 '14 00:12 vladima