TypeScript definitions for the VSCode API - optimized for Deno and JSR
This package provides comprehensive TypeScript type definitions for the Visual Studio Code Extension API, specifically adapted for use with Deno and the JSR package registry. It enables you to develop VSCode extensions using modern Deno tooling while maintaining full type safety and IntelliSense support.
β
Complete VSCode API Coverage - All VSCode extension APIs and types
β
Deno-Native - No Node.js dependencies, works directly with Deno
β
JSR-Optimized - Built for the JSR package registry
β
ESM Compatible - Modern ES module structure
β
Type-Safe - Full TypeScript strict mode compliance
β
Up-to-Date - Automatically synced with upstream @types/vscode
# Add to your Deno project
deno add @typed/vscode
# Or install globally for CLI usage
deno install --global @typed/vscode
{
"imports": {
"vscode": "jsr:@typed/vscode"
}
}
import * as vscode from "@typed/vscode";
export function activate(context: vscode.ExtensionContext): void {
console.log('Extension activated!');
// Register a command
const disposable = vscode.commands.registerCommand('extension.helloWorld', () => {
vscode.window.showInformationMessage('Hello World from Deno!');
});
context.subscriptions.push(disposable);
}
export function deactivate(): void {
console.log('Extension deactivated');
}
import * as vscode from "@typed/vscode";
// Window management
vscode.window.showInformationMessage("Hello from Deno!");
vscode.window.showErrorMessage("Error occurred", "Retry", "Cancel");
// Workspace operations
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
const config = vscode.workspace.getConfiguration('myExtension');
// Document and editor operations
const activeEditor = vscode.window.activeTextEditor;
if (activeEditor) {
const document = activeEditor.document;
const selection = activeEditor.selection;
// Type-safe operations on document and selection
}
// Language features
vscode.languages.registerCompletionItemProvider('typescript', {
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {
const completions: vscode.CompletionItem[] = [];
// Add your completion logic
return completions;
}
});
import * as vscode from "@typed/vscode";
// File system events
vscode.workspace.onDidChangeTextDocument((event: vscode.TextDocumentChangeEvent) => {
console.log(`Document changed: ${event.document.fileName}`);
});
// Window events
vscode.window.onDidChangeActiveTextEditor((editor: vscode.TextEditor | undefined) => {
if (editor) {
console.log(`Active editor: ${editor.document.fileName}`);
}
});
This package is optimized for the VSCode Web Extensions runtime as our pragmatic path to bringing VSCode extension development to Deno. While our ideal would be full parity with the Node.js extension development environment, the web extension runtime represents the best available approach given current VSCode architecture limitations.
The Reality:
- π― Goal: Enable Deno-native VSCode extension development
β οΈ Challenge: VSCode's extension host is deeply integrated with Node.js- β Solution: Leverage the web extension runtime for Deno compatibility
- πͺ Future: Working toward fuller Node.js runtime parity as the ecosystem evolves
The web extension runtime enables you to create extensions that run everywhere - both desktop VSCode and web-based environments (vscode.dev, github.dev, GitHub Codespaces):
import * as vscode from "@typed/vscode";
// Web extensions run on BOTH desktop and web VSCode
export function activate(context: vscode.ExtensionContext): void {
// Full VSCode API support: TreeView, Commands, Language Features, etc.
const provider = new MyTreeDataProvider();
vscode.window.createTreeView('myView', { treeDataProvider: provider });
// Limitation: Node.js APIs are not available (browser sandbox restrictions)
// But the extension works identically on desktop and web!
}
Key Benefits:
- β Universal compatibility - One extension runs on desktop AND web VSCode
- β Full VSCode API access - Commands, UI, language features, etc.
- β Modern deployment - Works in vscode.dev, github.dev, Codespaces
β οΈ Browser limitations - No Node.js/filesystem APIs (applies to web runtime only)
@typed/vscode
is part of a complete ecosystem for Deno-based VSCode extension development. Explore these complementary packages:
@vsce/cli - Command-line tools for Deno VSCode extensions
deno add @vsce/cli
- Project scaffolding and templates
- Development server with hot reload
- Build and packaging utilities
- Extension testing and validation
@vsce/create - Project generator for new extensions
deno add @vsce/create
- Interactive project setup
- Multiple template options (basic, language server, tree view, etc.)
- Deno-optimized project structure
- Best practices and conventions built-in
@vsce/bundler - Web extension bundler for Deno
deno add @vsce/bundler
- Bundle Deno code for VSCode web extensions
- Tree shaking and optimization
- Source map support
- Multi-target builds (desktop + web)
@vsce/testing - Testing utilities for VSCode extensions
deno add @vsce/testing
- Mock VSCode APIs for unit testing
- Extension host simulation
- Language server testing utilities
- TreeView and UI component testing
// extension.ts - Built with the full @vsce ecosystem
import * as vscode from "@typed/vscode";
import { createLanguageServer } from "@vsce/cli";
import { MockExtensionContext } from "@vsce/testing";
export async function activate(context: vscode.ExtensionContext): Promise<void> {
// Full ecosystem integration example
const server = await createLanguageServer({
name: 'my-language-server',
languages: ['typescript', 'javascript']
});
context.subscriptions.push(
vscode.languages.registerHoverProvider(['typescript'], server),
vscode.languages.registerCompletionItemProvider(['typescript'], server)
);
}
Environment | Support | Notes |
---|---|---|
VSCode Desktop | β Full | All APIs available |
VSCode Web | β Most APIs | No Node.js/filesystem APIs |
Deno Runtime | β Type-checking | For development and testing |
GitHub Codespaces | β Full | Web + server APIs |
vscode.dev | β Web APIs | Browser-based development |
This package includes types for all major VSCode API areas:
- Core APIs: Commands, Configuration, Extensions
- Editor APIs: TextEditor, TextDocument, Selection
- Language APIs: Completion, Hover, Diagnostics, LSP
- UI APIs: TreeView, WebView, StatusBar, QuickPick
- Workspace APIs: Files, Folders, Settings, Tasks
- Debug APIs: Debug Sessions, Breakpoints, Variables
- Terminal APIs: Integrated Terminal, Task Running
- SCM APIs: Source Control Management
- Authentication APIs: Auth Providers, Secrets
This package is automatically generated and maintained. For issues:
- Type definitions: Report at typed-vscode repository
- Ecosystem packages: Each
@vsce/*
package has its own repository - Upstream VSCode types: Report at DefinitelyTyped
@typed/vscode | VSCode API | Status |
---|---|---|
1.96.x | VSCode 1.96+ | β Current |
1.95.x | VSCode 1.95+ | π‘ Maintenance |
< 1.95 | Older versions | β Deprecated |
The package version follows the VSCode API version for compatibility.
MIT License - see LICENSE for details.
Happy coding with Deno + VSCode! π¦β‘
Part of the @vsce ecosystem for Deno-based VSCode extension development.