-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Debugging Language Service in VS Code
VS Code is designed around an extension model. This means that the client-side (ie: text-editor) code for communicating with the TypeScript server lives in "extensions/typescript" in the VS Code repo.1
The server side code lives in src/services
of the TypeScript repo.
We will use a stable version of vscode to debug a development version of vs code running against a development version of tsserver.
-
Download/install a stable version of vs code.
-
Follow the instructions to setup a development version of vs code.1
-
Clone the typescript repo locally, and follow the instructions on building typescript.
-
Update your user settings to use your development version of typescript, located in the
.../TypeScript/built/local
directory. The corresponding setting/path is
{
"typescript.tsdk": "/path/to/repo/TypeScript/built/local"
}
From here, there are different steps for debugging the client- and server-side, respectively.
Note: the gulp-build doesn't currently produce working source-maps, and building with jake may require some extra effort to fix the source-maps.
- Set the ts-server to be open in debug mode on the right port using either of the following two methods (in the rest of this guide, we assume you chose 5859):
a. In a shell, export the TSS_DEBUG
environment variable to an open port (you will run the development vs code instance from within that shell).
b. Edit extensions/typescript/src/typescriptServiceClient.ts
, setting the port to an open one.
- Update launch.json with an option to attach to the node instance, with sourcemaps from your
built/local
folder. You can use this option as a template:
{
"name": "Attach to TS Server",
"type": "node",
"request": "attach",
"port": 5859,
"sourceMaps": true,
"outDir": "/path/to/repo/TypeScript/built/local"
},
-
Launch an instance of development vs code, and open a ts file.
-
Launch an instance of stable vs code.
-
Attach the stable vs code instance to the development instance.
-
Launch an instance of development vs code.
-
Launch an instance of stable vs code.
-
Attach the stable vs code instance to the development instance.
1 In particular, the built-in extension spawns the node instance that loads tsserver via the call to electron.fork() in extensions/typescript/src/typescriptServiceClient.ts
.
2 If you are on Linux, be sure to increase the number of file watchers per the fix for ENOSPC errors. for opening medium-large projects like Typescript, the default limit of 8192 is almost certainly too small.
News
Debugging TypeScript
- Performance
- Performance-Tracing
- Debugging-Language-Service-in-VS-Code
- Getting-logs-from-TS-Server-in-VS-Code
- JavaScript-Language-Service-in-Visual-Studio
- Providing-Visual-Studio-Repro-Steps
Contributing to TypeScript
- Contributing to TypeScript
- TypeScript Design Goals
- Coding Guidelines
- Useful Links for TypeScript Issue Management
- Writing Good Design Proposals
- Compiler Repo Notes
- Deployment
Building Tools for TypeScript
- Architectural Overview
- Using the Compiler API
- Using the Language Service API
- Standalone Server (tsserver)
- TypeScript MSBuild In Depth
- Debugging Language Service in VS Code
- Writing a Language Service Plugin
- Docker Quickstart
FAQs
The Main Repo