- Notifications
You must be signed in to change notification settings - Fork 0
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 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/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. for opening medium-large projects like Typescript, the default limit of 8192 is almost certainly too small.
TypeScript Language Basics
- Basic Types
- Interfaces
- Classes
- Namespaces and Modules
- Functions
- Generics
- Compiler Options
- tsconfig.json
- Integrating with Build Tools
- Nightly Builds
TypeScript Language Advanced
- Mixins
- Declaration Merging
- Type Inference
- Type Compatibility
- JSX
- Writing Declaration Files
- Typings for NPM packages
News
TypeScript Contributors
- Contributing to TypeScript
- TypeScript Design Goals
- Coding Guidelines
- Spec conformance testing
- Useful Links for TypeScript Issue Management
- Writing Good Design Proposals
- Compiler Internals
Building Tools for TypeScript
- Architectural Overview
- Using the Compiler API
- Using the Language Service API
- Dev Mode in Visual Studio
- Debugging Language Service in VS Code
FAQs