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

Hide private members (e.g. methods) from IntelliSense. (Node / JSDoc) #107894

Closed
infacto opened this issue Oct 1, 2020 · 4 comments
Closed

Hide private members (e.g. methods) from IntelliSense. (Node / JSDoc) #107894

infacto opened this issue Oct 1, 2020 · 4 comments

Comments

@infacto
Copy link

infacto commented Oct 1, 2020

Is there a way to hide private methods from the autocomplete list? For example:

const log = {
  /** @private */
  somethingPrivate: () => {/* ... */},

  info: () => {/* ... */},
  warn: () => {/* ... */},
  error: () => {/* ... */},
  success: () => {/* ... */},
};

This does not work. The method is still shown in list. But with the doc comment label "private".
It should be hidden. Or is there a separate label for this?

image

Version: 1.49.2 (user setup)
Commit: e5e9e69aed6e1984f7499b7af85b3d05f9a6883a
Date: 2020-09-24T16:29:41.983Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.19041
@vscodebot
Copy link

vscodebot bot commented Oct 1, 2020

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@infacto
Copy link
Author

infacto commented Oct 1, 2020

Nope, mr bot, this is not a duplicate. My issue is about hiding. The other issue is about weird characters in the method name. But interesting that this user want to see it. In my opinion private members should be hidden from outside like in TypeScript.
Update: Also tried with //@ts-check. Does not work... But great feature to detect e.g. if an object is used like a function or detect undefined variables. Maybe we can include this private-flag?

@jrieken
Copy link
Member

jrieken commented Oct 1, 2020

Having /** @private */ has no semantics. In TS you can use the private keyword, in modern (and upcoming) JS you can use the #-prefix to mark something as private. It will then be hidden from IntelliSense. If you want support for the jsdoc comment, I'd suggest to file an issue directly against TypeScript: https://github.com/Microsoft/TypeScript

@jrieken jrieken closed this as completed Oct 1, 2020
@infacto
Copy link
Author

infacto commented Oct 1, 2020

#-prefix only works for class members. Private identifiers are not allowed outside class bodies. And I think that /** @private */ should be handled like other labels e.g. /** @param {number} universalAnswer */. Also if this is not "really" private. ... But thanks for the info. VS Code JS IntelliSense comes from TypeScript? Ok, I consider to file an issue there. Thanks.

Update: Other related issue: #22329 and microsoft/TypeScript#14009
The private-tag in doc comment works with classes only. It's ok.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants