github fuma-nama/fumadocs fumadocs-twoslash@4.0.0

4 hours ago

Run Twoslash on TypeScript 7

fumadocs-twoslash now runs on the native TypeScript 7 compiler (typescript/unstable/sync) instead of bundling its own TypeScript 6, so the types in popups come from the same compiler as your project.

Code blocks of documents compiled concurrently are analyzed together in one snapshot of the TypeScript project (requires fumadocs-core 16.15.7 for the _fd_prepare hook of rehype-code), which removes most of the per-block cost of loading the project. Cold builds of the Fumadocs docs take 40% less time in total, with the TypeScript part 3.5x faster.

The Shiki transformer and renderer are now implemented in fumadocs-twoslash, @shikijs/twoslash and twoslash are no longer dependencies (nor twoslash a peer of TypeScript 6). The rendered HTML and the transformer options are unchanged, except that rendererRich only takes the options that apply to the popups of Fumadocs (jsdoc, processHoverInfo, processHoverDocs, completionIcons, customTagIcons); the hast extensions, errorRendering, queryRendering, classExtra and the custom renderer option are removed.

The twoslashOptions are simplified to what the native API supports:

  • compilerOptions takes tsconfig.json values (e.g. moduleResolution: 'bundler') instead of enum values from the typescript package.
  • cwd replaces vfsRoot.
  • tsModule, tsLibDirectory, fsMap, cache, customTransformers and the per-call positionQueries, positionCompletions, positionHighlights are removed.
  • @showEmit is not supported, TypeScript 7 has no emit API yet.
transformerTwoslash({
  twoslashOptions: {
    compilerOptions: {
      types: ['node'],
    },
  },
});

Don't miss a new fumadocs release

NewReleases is sending notifications on new releases.