Skip to content

Commit c586eb9

Browse files
authored
fix(twoslash): pass-through unrecognized options.lang to codeToHast (#1047)
1 parent e1f8855 commit c586eb9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/twoslash/src/renderer-rich.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ export function rendererRich(options: RendererRichOptions = {}): TwoslashRendere
232232

233233
const popupContents: ElementContent[] = []
234234

235+
let lang = this.options.lang
236+
if (lang === 'jsx')
237+
lang = 'tsx'
238+
else if (lang === 'js' || lang === 'javascript')
239+
lang = 'ts'
240+
235241
const typeCode: Element = {
236242
type: 'element',
237243
tagName: 'code',
@@ -242,9 +248,7 @@ export function rendererRich(options: RendererRichOptions = {}): TwoslashRendere
242248
...this.options,
243249
meta: {},
244250
transformers: [],
245-
lang: (this.options.lang === 'tsx' || this.options.lang === 'jsx')
246-
? 'tsx'
247-
: 'ts',
251+
lang,
248252
structure: content.trim().includes('\n') ? 'classic' : 'inline',
249253
},
250254
).children as ElementContent[],

0 commit comments

Comments
 (0)