# tsserver-lean

> lean subset of tsserver that only supports typechecking

Latest version **0.0.0-pre-alpha.8** (published 2023-05-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install tsserver-lean
pnpm add tsserver-lean
yarn add tsserver-lean
bun add tsserver-lean
```

Provides the command `tsserver-lean`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.0-pre-alpha.8 |
| Published | 2023-05-17 |
| First published | 2023-04-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 80 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | ruiconti |

## Links

- npm: https://www.npmjs.com/package/tsserver-lean
- Repository: https://github.com/microsoft/ori
- Homepage: https://github.com/microsoft/ori#readme
- Issues: https://github.com/microsoft/ori/issues
- npm.io page: https://npm.io/package/tsserver-lean

## Dependencies (6)

- [ws](https://npm.io/package/ws.md) ^8.8.1
- [uuid](https://npm.io/package/uuid.md) ^9.0.0
- [resolve](https://npm.io/package/resolve.md) ^1.22.2
- [get-port](https://npm.io/package/get-port.md) ^6.1.2
- [tree-kill](https://npm.io/package/tree-kill.md) ^1.2.2
- [typescript](https://npm.io/package/typescript.md) ^5.0.4

## Recent versions

- 0.0.0-pre-alpha.8 (latest) — 2023-05-17
- 0.0.0-pre-alpha.7 — 2023-05-07
- 0.0.0-pre-alpha.6 — 2023-04-11
- 0.0.0-pre-alpha.5 — 2023-04-11
- 0.0.0-pre-alpha.4 — 2023-04-07
- 0.0.0-pre-alpha.2 — 2023-04-07
- 0.0.0-pre-alpha.1 — 2023-04-05

## README

# lean-tsserver

Implements a tiny sub-set of `tsserver`, also using different internal APIs. Its reason d'etré is to i) emit diagnostics for a particular TypeScript module; ii) doing the least amount of work possible.

## High-level working description

`tsserver-lean` expects communication to be done through its `stdin` and `stdout` pipes, like `tsserver`. It expects a set of requests defined in [`protocol.ts`](src/protocol.ts) that are mapped to responses in a handler, on [`session.ts`](src/session.ts).

After a refactor, we are now using TypeScript's `ProjectService` API, that is responsible for managing multiple configured projects. With current setup, that means that we have a `ProjectService` for each project that we've requested diagnostics for. It has several efficiency affordances like caching of many adjacent functionality (`ScriptInfo`, module resolution, dependency type checkings) and the ability to extract diagnostics directly from a source file.

## Contracts

There are some contracts and premises that is worth being aware of:

- `tsserver-lean` uses `readline` to read its input, so whenever we want to programmatically write to the process' stdin, it is required that a `\n` is added to the end of the request message.
- After each response, `tsserver-lean` will write a `\n` to its stdout, so it is required that the client reads until it finds a `\n` to know that the response has ended.

## Supported commands

So far, the only need for this server is to emit diagnostics for a particular module, on demand.

### Type check a module

```json
{ "command": "geterr", "type": "request", "seq": 0, "arguments": { "files": ["path/a/.ts", "path/b/.ts"] } }
```

### Handshake

Used as a first message sent to stdout to indicate a successful start-up.

```json
{ "command": "handshake", "type": "request", "seq": 0 }
```

---
_Source: https://npm.io/package/tsserver-lean · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
