Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix parsing with ts
  • Loading branch information
tobiasdiez committed Oct 13, 2023
commit 85460de93e0e74539d3973be9625069f1b82794c
5 changes: 4 additions & 1 deletion src/core/transform.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ParserPlugin } from '@babel/parser'
import { compile as compileMdx } from '@storybook/mdx2-csf'
import { format as prettierFormat } from 'prettier'
import type { SFCScriptBlock } from 'vue/compiler-sfc'
Expand All @@ -11,7 +12,9 @@ export async function transform(code: string) {
let result = ''
const { resolvedScript, meta, stories, docs } = parse(code)
if (resolvedScript) {
result += rewriteDefault(resolvedScript.content, '_sfc_main')
const isTS = resolvedScript.lang === 'ts'
const plugins: ParserPlugin[] = isTS ? ['typescript'] : []
result += rewriteDefault(resolvedScript.content, '_sfc_main', plugins)
result += '\n'
} else {
result += 'const _sfc_main = {}\n'
Expand Down