@rspress/plugin-twoslash
Integrates Twoslash with Rspress to generate rich TypeScript code blocks with type information.
Installation
Usage
1. Register the plugin
rspress.config.ts
2. Write code blocks with twoslash
Use special comments within TypeScript code blocks to enable Twoslash features.
For detailed usage, see the Twoslash documentation.
Extract type
Completions
Highlighting
Error
Config
The plugin accepts an object with the following type:
explicitTrigger
- Type:
boolean - Default:
true
Controls which TypeScript code blocks Twoslash processes. Set it to false to process all TypeScript code blocks, or to true to process only blocks marked twoslash.
cache
- Type:
boolean - Default:
true
Caches TypeScript language servers by compiler options when calling createTwoslasher.
twoslashOptions
- Type:
TwoslashOptions - Default:
undefined
Passes options to Twoslash, including TypeScript compiler options.