-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Support @var or @member JSDoc tagsΒ #56674
Copy link
Copy link
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureDomain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generationSuggestionAn idea for TypeScriptAn idea for TypeScript
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureDomain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generationSuggestionAn idea for TypeScriptAn idea for TypeScript
π Search Terms
jsdoc@var@memberβ Viability Checklist
β Suggestion
Recognize and support JSDoc's
@varor@membertags.π 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
Electron preload scripts and
contextBridge.exposeInMainWorld!Relies on JS's support of variable redeclaration. Changing
vartoletthrows the following error on runtime:Identifier 'ElectronAPI' has already been declaredThe 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):