whatisgithub

What is twoslash-1?

mattpocock/twoslash-1 — explained in plain English

Analysis updated 2026-07-13 · repo last pushed 2024-06-09

2Audience · developerComplexity · 2/5DormantLicenseSetup · moderate

In one sentence

Twoslash is a tool that automatically adds type annotations, error messages, and hover hints to your TypeScript code examples for documentation. It uses the TypeScript compiler to pull this information so your docs stay accurate as your code changes.

Mindmap

mindmap
  root((repo))
    What it does
      Adds type info to code samples
      Shows editor errors as text
      Captures hover tooltips
    Use cases
      Library docs
      Blog posts with TS
      Tutorial code examples
    Tech stack
      TypeScript
      TypeScript Compiler
    Audience
      Documentation writers
      Library maintainers
      Tutorial authors
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add accurate type annotations and error messages to code samples in your library's documentation.

USE CASE 2

Write blog posts with TypeScript examples that show hover tooltips as static text.

USE CASE 3

Create tutorials where readers see the same helpful context their editor would display.

What is it built with?

TypeScriptTypeScript Compiler

How does it compare?

mattpocock/twoslash-10-bingwu-0/live-interpreter0xkaz/llm-governance-dashboard
Stars222
LanguagePythonPython
Last pushed2024-06-09
MaintenanceDormant
Setup difficultymoderatemoderatehard
Complexity2/52/54/5
Audiencedevelopergeneralops devops

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires a TypeScript project setup and integration with a documentation renderer or Markdown pipeline.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

So what is it?

Twoslash is a tool that helps you write better TypeScript documentation. When you're showing code examples in a tutorial, blog post, or docs site, you often want to display extra information like type annotations, error messages, or hover hints, the kind of helpful context your code editor shows you. This project provides a markup format that lets TypeScript itself generate that information ahead of time, so your readers get richer, more informative code samples without you having to manually type out every detail. At a high level, you write TypeScript code with some special markup mixed in. Twoslash then runs that code through the TypeScript compiler and extracts the type information, errors, and other metadata automatically. The result is a self-contained code sample where all the useful context is baked in, think of it like having your editor's hover tooltips and inline errors captured and displayed as static text that anyone can read in a browser. The main audience is people writing TypeScript documentation or tutorials. If you maintain a library and want your docs to show exactly what types a function returns, or what error a user would see if they pass the wrong argument, this saves you from manually writing and maintaining all of that information by hand. Instead of typing out a comment saying "this returns a Promise<string>," the tool pulls that detail directly from the compiler, so your examples stay accurate even as your code changes. This is the successor to an earlier tool called @typescript/twoslash that was part of the TypeScript website. The README is sparse on implementation details, but it points to separate documentation for a deeper dive and a migration guide if you're coming from the older version. The project is maintained by Orta Therox, Anthony Fu, and Microsoft under an MIT license.

Copy-paste prompts

Prompt 1
Help me set up Twoslash in my docs site so my TypeScript code examples automatically show type annotations and error messages inline.
Prompt 2
I have a TypeScript code block in my README that I want to enhance with hover tooltips and compiler errors using Twoslash markup. Here is the code: <paste code>
Prompt 3
I'm migrating from @typescript/twoslash to the new Twoslash package. Walk me through what changed and how to update my setup.
Prompt 4
Show me how to write Twoslash markup in a Markdown code block so that type information and errors are rendered as static text for readers.

Frequently asked questions

What is twoslash-1?

Twoslash is a tool that automatically adds type annotations, error messages, and hover hints to your TypeScript code examples for documentation. It uses the TypeScript compiler to pull this information so your docs stay accurate as your code changes.

Is twoslash-1 actively maintained?

Dormant — no commits in 2+ years (last push 2024-06-09).

What license does twoslash-1 use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is twoslash-1 to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is twoslash-1 for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.