-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[Discussion] Better Way to Declare Globals in JavaScript files #15626
Copy link
Copy link
Open
Labels
Domain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specificallyNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScriptVS Code TrackedThere is a VS Code equivalent to this issueThere is a VS Code equivalent to this issue
Metadata
Metadata
Assignees
Labels
Domain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specificallyNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScriptVS Code TrackedThere is a VS Code equivalent to this issueThere is a VS Code equivalent to this issue
Type
Fields
Give feedbackNo fields configured for issues without a type.
Problem
Using the new
checkJsfeature, it is currently difficult to tell TypeScript about a global variable:The only way around this that I know is to create a
.d.tsfile that defines these:JavaScript users should not have to write
*.d.tsfiles.Possible Approaches
@egamma proposes that may be able to use the
globalcomment from ESlint http://eslint.org/docs/user-guide/configuring :/* global var1, var2 */I'd also be interested to see if we could put type information in a jsdoc somehow, something like: