TypeScript LSP
TypeScript/JavaScript language server integration providing comprehensive code intelligence through typescript-language-server.
Capabilities
- Type checking: Static analysis of TypeScript and JavaScript types
- Code intelligence: Autocomplete, go-to-definition, find references, rename symbols
- Error detection: Real-time diagnostics for type errors, syntax issues, and semantic problems
- Refactoring: Extract function/variable, organize imports, quick fixes
- Supported extensions:
.ts, .tsx, .js, .jsx, .mts, .cts, .mjs, .cjs
Installation
Install TypeScript language server and TypeScript compiler:
npm install -g typescript-language-server typescript
Or with yarn:
yarn global add typescript-language-server typescript
Verify installation:
typescript-language-server --version
tsc --version
Usage
The language server runs automatically in LSP-compatible editors. For manual type checking:
tsc --noEmit # Type check without generating output files
Compile TypeScript files:
tsc src/index.ts
Watch mode for continuous type checking:
tsc --watch --noEmit
Configuration
Create tsconfig.json in project root:
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"moduleResolution": "node"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
Integration Pattern
When editing TypeScript/JavaScript code:
- Run
tsc --noEmit after significant changes
- Address type errors before committing
- Use
tsc --watch during active development
- Leverage quick fixes for common issues
Common Flags
--noEmit: Type check only, no output files
--strict: Enable all strict type checking options
--watch: Watch mode for continuous compilation
--project <path>: Specify tsconfig.json location
--pretty: Stylize errors and messages
More Information
1---2name: typescript-lsp3description: TypeScript language server providing type checking, code intelligence, and LSP diagnostics for .ts, .tsx, .js, .jsx, .mts, .cts, .mjs, .cjs files. Use when working with TypeScript or JavaScript code that needs type checking, autocomplete, error detection, refactoring support, or code navigation.4---5
6# TypeScript LSP
7
8TypeScript/JavaScript language server integration providing comprehensive code intelligence through typescript-language-server.
9
10## Capabilities
11
12- **Type checking**: Static analysis of TypeScript and JavaScript types
13- **Code intelligence**: Autocomplete, go-to-definition, find references, rename symbols
14- **Error detection**: Real-time diagnostics for type errors, syntax issues, and semantic problems
15- **Refactoring**: Extract function/variable, organize imports, quick fixes
16- **Supported extensions**: `.ts`, `.tsx`, `.js`, `.jsx`, `.mts`, `.cts`, `.mjs`, `.cjs`
17
18## Installation
19
20Install TypeScript language server and TypeScript compiler:
21
22```bash
23npm install -g typescript-language-server typescript
24```
25
26Or with yarn:
27```bash
28yarn global add typescript-language-server typescript
29```
30
31Verify installation:
32```bash
33typescript-language-server --version
34tsc --version
35```
36
37## Usage
38
39The language server runs automatically in LSP-compatible editors. For manual type checking:
40
41```bash
42tsc --noEmit # Type check without generating output files
43```
44
45Compile TypeScript files:
46
47```bash
48tsc src/index.ts
49```
50
51Watch mode for continuous type checking:
52
53```bash
54tsc --watch --noEmit
55```
56
57## Configuration
58
59Create `tsconfig.json` in project root:
60
61```json
62{
63 "compilerOptions": {
64 "target": "ES2020",
65 "module": "ESNext",
66 "strict": true,
67 "esModuleInterop": true,
68 "skipLibCheck": true,
69 "forceConsistentCasingInFileNames": true,
70 "resolveJsonModule": true,
71 "moduleResolution": "node"
72 },
73 "include": ["src/**/*"],
74 "exclude": ["node_modules", "dist"]
75}
76```
77
78## Integration Pattern
79
80When editing TypeScript/JavaScript code:
811. Run `tsc --noEmit` after significant changes
822. Address type errors before committing
833. Use `tsc --watch` during active development
844. Leverage quick fixes for common issues
85
86## Common Flags
87
88- `--noEmit`: Type check only, no output files
89- `--strict`: Enable all strict type checking options
90- `--watch`: Watch mode for continuous compilation
91- `--project <path>`: Specify tsconfig.json location
92- `--pretty`: Stylize errors and messages
93
94## More Information
95
96- [typescript-language-server on npm](https://www.npmjs.com/package/typescript-language-server)
97- [GitHub Repository](https://github.com/typescript-language-server/typescript-language-server)
98- [TypeScript Official Documentation](https://www.typescriptlang.org/docs/)
99- [TypeScript Compiler Options](https://www.typescriptlang.org/tsconfig)