diff --git a/packages/twoslash/src/core.ts b/packages/twoslash/src/core.ts index 23ac215b4..67b794d1a 100644 --- a/packages/twoslash/src/core.ts +++ b/packages/twoslash/src/core.ts @@ -129,7 +129,7 @@ export function createTransformerFactory( catch (error) { const result = onTwoslashError(error, code, lang, this.options) if (typeof result === 'string') - return code + return result } } }, diff --git a/packages/vitepress-twoslash/src/index.ts b/packages/vitepress-twoslash/src/index.ts index c971fd263..9b4383187 100644 --- a/packages/vitepress-twoslash/src/index.ts +++ b/packages/vitepress-twoslash/src/index.ts @@ -19,7 +19,7 @@ export function transformerTwoslash(options: VitePressPluginTwoslashOptions = {} explicitTrigger = true, } = options - const onError = (error: any, code: string): void => { + const onError = (error: any, code: string): string | void => { const isCI = typeof process !== 'undefined' && process?.env?.CI const isDev = typeof process !== 'undefined' && process?.env?.NODE_ENV === 'development' const shouldThrow = (options.throws || isCI || !isDev) && options.throws !== false @@ -28,7 +28,7 @@ export function transformerTwoslash(options: VitePressPluginTwoslashOptions = {} throw error else console.error(error) - removeTwoslashNotations(code) + return removeTwoslashNotations(code) } const twoslash = createTransformerFactory(