Skip to content

Commit e86b0a7

Browse files
authored
fix(twoslash): fix onTwoslashError return value handling (#1070)
1 parent f66ddc7 commit e86b0a7

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/twoslash/src/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function createTransformerFactory(
129129
catch (error) {
130130
const result = onTwoslashError(error, code, lang, this.options)
131131
if (typeof result === 'string')
132-
return code
132+
return result
133133
}
134134
}
135135
},

packages/vitepress-twoslash/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function transformerTwoslash(options: VitePressPluginTwoslashOptions = {}
1919
explicitTrigger = true,
2020
} = options
2121

22-
const onError = (error: any, code: string): void => {
22+
const onError = (error: any, code: string): string | void => {
2323
const isCI = typeof process !== 'undefined' && process?.env?.CI
2424
const isDev = typeof process !== 'undefined' && process?.env?.NODE_ENV === 'development'
2525
const shouldThrow = (options.throws || isCI || !isDev) && options.throws !== false
@@ -28,7 +28,7 @@ export function transformerTwoslash(options: VitePressPluginTwoslashOptions = {}
2828
throw error
2929
else
3030
console.error(error)
31-
removeTwoslashNotations(code)
31+
return removeTwoslashNotations(code)
3232
}
3333

3434
const twoslash = createTransformerFactory(

0 commit comments

Comments
 (0)