- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.1k
 
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/localdirectory. 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.
- 
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)[http://stackoverflow.com/questions/1158091/defining-a-variable-with-or-without-export] the
TSS_DEBUGenvironment variable to an open port (you will run the development vs code instance from within that shell). b. Editextensions/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/localfolder. 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)[https://github.com/Microsoft/vscode/wiki/How-to-Contribute#incremental-build]. 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