Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observe @private and @protected in JSDocs for Property Suggestions #14009

Closed
mjbvz opened this issue Feb 11, 2017 · 19 comments · Fixed by #35731
Closed

Observe @private and @protected in JSDocs for Property Suggestions #14009

mjbvz opened this issue Feb 11, 2017 · 19 comments · Fixed by #35731
Assignees
Labels
Committed The team has roadmapped this issue Domain: JavaScript The issue relates to JavaScript specifically Domain: JSDoc Relates to JSDoc parsing and type generation Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Feb 11, 2017

From: microsoft/vscode#5163

TypeScript Version: 2.2.0- 20170210

Code

class Foo {
    /**
     * abc docs 
     * 
     * @private
    */
    abc;

    /**
     * xyz docs
     * 
     * @public
     */
    xyz;

}

(new Foo()).|

Expected behavior:
When triggering suggestions on instances of Foo, an entry for abc is not returned.

Actual behavior:
All members of Foo are returned. The @private annotation seems to be ignored.

@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Feb 11, 2017
@mjbvz mjbvz changed the title Observer @private and @protected in JSDocs for Property Suggestions Observe @private and @protected in JSDocs for Property Suggestions Feb 13, 2017
@mhegazy mhegazy added Salsa Suggestion An idea for TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation labels Feb 22, 2017
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.2 milestone Aug 13, 2018
@RyanCavanaugh RyanCavanaugh added the Experience Enhancement Noncontroversial enhancements label Aug 13, 2018
@s-bauer
Copy link

s-bauer commented Oct 12, 2018

Any update on this?

@weswigham weswigham added In Discussion Not yet reached consensus Domain: JavaScript The issue relates to JavaScript specifically and removed Salsa labels Nov 6, 2018
@labs-dlugo
Copy link

This would be great to have

@Samlv9
Copy link

Samlv9 commented Jan 4, 2019

The @internal also does not work.

image

@vschoener
Copy link

Hello,

Any news about this one? I got the same issue working with last TypeScript version (3.3333) I can access my protected property from the instance.

@sandersn sandersn modified the milestones: TypeScript 3.4.0, Backlog Mar 12, 2019
@dschnare
Copy link

This seems to keep getting punted. Now that TS 3.4.5 is out I expect this to be punted to 3.5.0?

Granted this is not a massive pain right now, but it would be a really great feature to have supported by TS out of the box.

@RyanCavanaugh RyanCavanaugh removed the Experience Enhancement Noncontroversial enhancements label Jul 29, 2019
@RyanCavanaugh RyanCavanaugh added Committed The team has roadmapped this issue and removed In Discussion Not yet reached consensus labels Jul 29, 2019
@ulrichb
Copy link

ulrichb commented Sep 11, 2019

  • Is it planned that the @private/ @protected JSDoc only affects the IDE completion, or also the compilation (like the private/protected modifier)?
  • Is it planned to respect the current scope for the invocation of the completion (like the private/protected modifier)?

@sandersn
Copy link
Member

It will work as much like private and protected as is possible given the definition on jsdoc.app.

@ulrichb
Copy link

ulrichb commented Sep 13, 2019

@sandersn Okay thanks for info.

I have a use case where I need to affect just the code completion. (Sth, like /** @hidden */). But I think I should create an own issue for that ...

@sandersn
Copy link
Member

So, no completions, but also no errors when you use it? It sounds like you want allowJs without checkJs, which is the default for JS files in VS Code.

@sandersn
Copy link
Member

sandersn commented Oct 7, 2019

Here's some documentation for future me to explain why this is surprisingly hard to do well.

There are four solutions I've come up with:

  1. The obvious way: All places that handle private and protected ModifierFlags now also need to check for @private or @protected flags. You have to write code to handle errors, declaration emit and completions separately.
  2. The right way: Make getModifierFlags check for JSDoc as well. Unfortunately, getModifierFlags caches, and is first called during parsing when node flags and parents haven't been set. Retrieval of JSDoc relies on both.
  3. The fragile right way: Remove all calls to getModifierFlags in the parser so that it can retrieve JSDoc. Unfortunately, all calls are indirect, so it's quite difficult to make sure getModifierFlags calls don't sneak back in. It really needs to assert that the compilation phase is post-parsing, or that parent pointers are set, or something.
  4. Change node construction so that flags and parent pointers are set on construction. I'm not sure why they're set at the end of their respective parsing functions right now, but changing this naively Broke Every Test, so I suspect this design has an important architectural reason.

(2) doesn't work. (3) might be worth trying if I can find an appropriate assert to prevent mistakes. (1) is a good fallback. (4) is probably not worth it (and may be practically impossible).

@panoply
Copy link

panoply commented Nov 29, 2019

Additionally it would great if JavaScript proposal class properties (which is at stage 3) could handled correctly as well, eg:

class  Something {
   #private =  'foo'
}

@sandersn sandersn moved this from Feature to In Progress in Rolling Work Tracking Dec 14, 2019
Rolling Work Tracking automation moved this from In Progress to Done Dec 18, 2019
@ekr3peeK
Copy link

ekr3peeK commented Jul 9, 2020

Was this feature implemented already, or will it be in the near future?

@sandersn
Copy link
Member

sandersn commented Jul 9, 2020

Looks like 3c5ecc2 is in 3.8 and above.

@ekr3peeK
Copy link

ekr3peeK commented Jul 9, 2020

Hmm.. does that mean that if my VsCode uses TypeScript 3.9.4, I should have access to this feature? Cause I don't:)

@panoply
Copy link

panoply commented Jul 9, 2020

Install JavaScript and TypeScript Nightly:

https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-next

@leosdad
Copy link

leosdad commented Jul 9, 2020

Install JavaScript and TypeScript Nightly:

https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-next

I've just done it, but e.g. @private does nothing, at least for JS files. My TypeScript version is 4.0.0-dev.20200708, i.e. yesterday. Any clues?

@panoply
Copy link

panoply commented Jul 10, 2020

Double check your jsconfig.json or tsconfig.json and make sure to "allowJs": true

@ekr3peeK
Copy link

For me, this works ok with TypeScript 4.0.0-dev.20200708, but it wasn't working with 3.9.4

@leosdad
Copy link

leosdad commented Jul 10, 2020

Double check your jsconfig.json or tsconfig.json and make sure to "allowJs": true

Thanks. Did that in my tsconfig.json, updated to dev.20200709, restarted VS Code twice, but nothing changes. Methods marked as @private still appear nonetheless. Any other conditions I should check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Committed The team has roadmapped this issue Domain: JavaScript The issue relates to JavaScript specifically Domain: JSDoc Relates to JSDoc parsing and type generation Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Projects
Development

Successfully merging a pull request may close this issue.