Skip to content

Support @var or @member JSDoc tags #56674

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

Open
6 tasks done
LqdBcnAtWork opened this issue Dec 5, 2023 · 1 comment
Open
6 tasks done

Support @var or @member JSDoc tags #56674

LqdBcnAtWork opened this issue Dec 5, 2023 · 1 comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: JSDoc Relates to JSDoc parsing and type generation Suggestion An idea for TypeScript

Comments

@LqdBcnAtWork
Copy link

πŸ” Search Terms

jsdoc
@var
@member

βœ… Viability Checklist

⭐ Suggestion

Recognize and support JSDoc's @var or @member tags.

πŸ“ƒ Motivating Example

It will allow the declaration of globals in JS files that use JSDoc for checking that are not declared within that specific file.

This will then allow for tools and tool chains that add to the global scope for a file or program to be documented without using ts, d.ts or other ts exclusive notation and features.

πŸ’» Use Cases

  1. What do you want to use this for?

Electron preload scripts and contextBridge.exposeInMainWorld!

  1. What workarounds are you using in the meantime?
/**@type {import("./preload.js").ElectronAPI} */
var ElectronAPI;
  1. What shortcomings exist with current approaches?

Relies on JS's support of variable redeclaration. Changing var to let throws the following error on runtime:

Identifier 'ElectronAPI' has already been declared

The following should do the same as the two lines above, but neither vscode nor TS supports it.

/** @var {import("./preload.js").ElectronAPI} ElectronAPI */

It does not rely on confusion inducing variable redeclaration and is much cleaner.

I believe it is also a way to declare members of a class without declaring them at the root level of the class.

These should be the same (as far as TS is concerned):

class test1{
    /**@type {string}*/
    name;
}

class test2{
    /**@var {string} name */
}
@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: JSDoc Relates to JSDoc parsing and type generation labels Dec 8, 2023
@Mouvedia
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: JSDoc Relates to JSDoc parsing and type generation Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants