hn.today

Microsoft Announces Type Server Protocol, Extension of Language Server Protocol

github.com236 points157 comments
Screenshot of Microsoft Announces Type Server Protocol, Extension of Language Server Protocol

The Type Server Protocol (TSP) defines a JSON-RPC interface for clients to obtain Python type-analysis data from a server that maintains analysis state for a workspace. It reuses useful Language Server Protocol conventions, including positions, ranges, and URI strings, while using methods prefixed with `typeServer/`. Its requests cover protocol-version checks, snapshots, Python search paths, import resolution, and computed, declared, and expected types. Semantic versions let clients and servers check compatibility; during the current 0.x series, minor-version changes may be breaking, while patch changes remain compatible within a minor line.

A typical session initializes shared workspace and document state, checks the server’s protocol version, obtains a snapshot identifier, then makes analysis requests against that view. Snapshots advance whenever changes could invalidate prior results, such as edits, configuration changes, or dependency updates; requests using stale snapshots should fail in a way that lets clients retry. Optional multi-connection mode allows concurrent, read-only requests over extra IPC channels, but the main connection retains all workspace updates, lifecycle traffic, and connection control. Client and server must negotiate a shared transport during initialization, and the server must also work without extra channels. Extra connections accept only version-approved, read-only TSP requests, and their results apply to the requested snapshot.

Read on github.com157 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.