Skip to content

Conversation

@Karibash
Copy link
Contributor

Summary

Added compilerOptions option to @rspress/plugin-twoslash to allow customization of TypeScript compiler options used by Twoslash.
When displaying type information in code blocks with Twoslash, there are cases where you want to apply project-specific TypeScript compiler options. This feature allows you to flexibly customize the TypeScript environment used in code blocks within documentation.

Usage Example

import { defineConfig } from '@rspress/core';
import { pluginTwoslash } from '@rspress/plugin-twoslash';
import { JsxEmit } from 'typescript';

export default defineConfig({
  plugins: [
    pluginTwoslash({
      compilerOptions: {
        jsx: JsxEmit.ReactJSX
      },
    }),
  ],
});

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings November 17, 2025 15:16
@netlify
Copy link

netlify bot commented Nov 17, 2025

Deploy Preview for rspress-v2 ready!

Name Link
🔨 Latest commit c6fe356
🔍 Latest deploy log https://app.netlify.com/projects/rspress-v2/deploys/691c72f19e404a000852c0fb
😎 Deploy Preview https://deploy-preview-2773--rspress-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for customizing TypeScript compiler options in the Twoslash plugin through a new compilerOptions configuration option. This enables users to apply project-specific TypeScript settings when displaying type information in documentation code blocks.

  • Added compilerOptions option to PluginTwoslashOptions interface
  • Configured the option to be passed through to the underlying transformerTwoslash function
  • Updated documentation in both English and Chinese to describe the new option

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/plugin-twoslash/src/index.ts Added CompilerOptions type import and new compilerOptions property to plugin options, passing it to transformerTwoslash
packages/plugin-twoslash/package.json Added TypeScript as a peer dependency to support the CompilerOptions type
website/docs/en/plugin/official-plugins/twoslash.mdx Added English documentation for the new compilerOptions configuration option
website/docs/zh/plugin/official-plugins/twoslash.mdx Added Chinese documentation for the new compilerOptions configuration option

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Karibash Karibash force-pushed the feature/twoslash-compiler-options branch from dd012d0 to c59814e Compare November 17, 2025 23:26
Copy link
Member

@SoonIter SoonIter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job!

@SoonIter SoonIter merged commit de20873 into web-infra-dev:main Nov 19, 2025
9 checks passed
@Karibash Karibash deleted the feature/twoslash-compiler-options branch December 8, 2025 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants