on-internet
← Community

JSDoc: How to specify the type of an implicit global variable for a JS code snippet?

Stack Overflow ·

I have a JavaScript file that is being run with eval() by a VSCode extension. When the script is evaluated, its context already includes the global variable vscode (the VSCode API) which I am using from my script. All of that works fine. What I want to know: Is there a way to use JSDoc annotations / TypeScript type definition files to tell VSCode that the vscode variable exists in the context? I have tried this (I'm not sure if it makes any sense) and it didn't help: // @ts-check /// <reference path="node_modules/@types/vscode/index.d.ts" /> What does work is if I write: const vscode = require

Comments

Sign in or sign up to comment and upvote.

No comments yet.