8000 fix(twoslash): respect twoslash output lang · antfu/shikiji@a5a8aba · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit a5a8aba

Browse files
committed
fix(twoslash): respect twoslash output lang
1 parent 043524a commit a5a8aba

File tree

1 file changed

+6
-9
lines changed
  • packages/shikiji-twoslash/src

1 file changed

+6
-9
lines changed

packages/shikiji-twoslash/src/core.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ export * from './icons'
1818
export function defaultTwoSlashOptions(): TwoSlashExecuteOptions {
1919
return {
2020
customTags: ['annotate', 'log', 'warn', 'error'],
21-
compilerOptions: {
22-
module: 99 satisfies ModuleKind.ESNext,
23-
target: 99 satisfies ScriptTarget.ESNext,
24-
},
2521
}
2622
}
2723

@@ -51,15 +47,16 @@ export function createTransformerFactory(
5147

5248
const filter = options.filter || ((lang, _, options) => langs.includes(lang) && (!explicitTrigger || /\btwoslash\b/.test(options.meta?.__raw || '')))
5349
return {
54-
preprocess(code, shikijiOptions) {
55-
let lang = shikijiOptions.lang
50+
preprocess(code) {
51+
let lang = this.options.lang
5652
if (lang in langAlias)
57-
lang = langAlias[shikijiOptions.lang]
53+
lang = langAlias[this.options.lang]
5854

59-
if (filter(lang, code, shikijiOptions)) {
60-
shikijiOptions.mergeWhitespaces = 'never'
55+
if (filter(lang, code, this.options)) {
56+
this.options.mergeWhitespaces = 'never'
6157
const twoslash = twoslasher(code, lang, twoslashOptions)
6258
this.meta.twoslash = twoslash
59+
this.options.lang = twoslash.meta.extension || lang
6360
return twoslash.code
6461
}
6562
},

0 commit comments

Comments
 (0)
0