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