@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
explicitTrigger is used to configure whether to explicitly trigger the Twoslash feature. Default is true.
- If set to
false, all TypeScript code blocks will be processed by default. - If set to
true, only code blocks with thetwoslashtag will be processed.
cache
cache is used to cache the TypeScript language servers based on compiler options when calling createTwoslasher. Default is true.
twoslashOptions
twoslashOptions is used to pass options to Twoslash.
This allows you to customize the Twoslash behavior, including TypeScript compiler options and other settings.