Skip to content

TypeSpec Extension for Visual Studio Code

Installation

Install the extension via the Visual Studio Code extension manager Visual Studio Marketplace

Features

The TypeSpec extension for Visual Studio Code enhances the development of TypeSpec by leveraging VS Codeā€™s powerful features. It provides:

  • IntelliSense and syntax highlighting
  • Code autocompletion and formatting
  • Live diagnostics and quick fixes
  • Refactoring tools (rename, go-to definition, etc.)
  • Seamless project setup and emitter configuration <new>
  • Import TypeSpec from existing OpenAPI 3 definitions <new>
  • Emit code from TypeSpec <new>
  • Preview API documentation <new>

Commands

The extension provides the following commands:

CommandDescription
TypeSpec: Create TypeSpec ProjectScaffold a new TypeSpec project.
TypeSpec: Install TypeSpec Compiler/CLI globallyInstall the TypeSpec Compiler/CLI globally.
TypeSpec: Generate From TypeSpecCompile and generate from TypeSpec files into the specified output.
TypeSpec: Restart TypeSpec ServerRestart the TypeSpec language server.
TypeSpec: Show Output ChannelOpen the TypeSpec output channel to view logs.
TypeSpec: Preview API DocumentationPreview API documentation generated from TypeSpec in the workspace.
TypeSpec: Import TypeSpec from OpenAPI 3Import TypeSpec from existing OpenAPI 3 definitions

Configuration

TypeSpec will interpolate a few variables using this pattern: ${<name>}. For example: ${workspaceFolder}.

Available variables:

  • workspaceFolder: Corresponds to the root of your Visual Studio workspace.

typespec.tsp-server.path: Configure the server path

There are cases where the TypeSpec project is located in a subfolder. In such cases, the TypeSpec extension is not able to find the tsp compiler automatically and needs a little guidance. This setting allows you to configure where the tsp compiler is located:

{
"typespec.tsp-server.path": "${workspaceFolder}/my-nested-project/node_modules/@typespec/compiler"
}

Uninstall

You can uninstall the extension via the Visual Studio Code extension manager or through the command line:

Terminal window
tsp code uninstall
# For VS Code insiders
tsp code uninstall --insiders

Telemetry

The extension for Visual Studio Code collects usage data and sends it to Microsoft to help improve our products and services. Read our privacy statement to learn more. This extension respects the telemetry.telemetryLevel setting which you can find more information in the FAQ.

What telemetry data are collected

  • OperationTelemetry
Telemetry nameTypeExample
EventNamestringā€start-extensionā€ for example
ActivityIdstring
StartTimedatatime
EndTimedatatime
Resultstringā€successā€,ā€œfailā€,ā€œcancelledā€, etc.
LastStepstring
  • OperationDetailTelemetry
Telemetry nameTypeExample
ActivityIdstring
EmitterNamestringThe extension will log only names of pre-defined emitters. Unknown emitters from customers will be masked to ensure privacy.
EmitterVersionstring
CompilerVersionstring
CompilerLocationstringā€global-compilerā€, ā€œlocal-compilerā€, etc. It is not to store the actual path of compiler being installed.
Errorstringtsp compiling errors