Skip to content

Commit a9c05a3

Browse files
committed
Fix: export never when failed to parse
1 parent 93e5193 commit a9c05a3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/createDts.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@ export const createDtsSnapshot = (
66
scriptSnapshot: ts.IScriptSnapshot
77
): ts.IScriptSnapshot => {
88
const text = scriptSnapshot.getText(0, scriptSnapshot.getLength())
9-
const data = toml.parse(text)
9+
let dts
10+
try {
11+
const data = toml.parse(text)
1012

11-
const dts = `
13+
dts = `
1214
declare const data = ${JSON.stringify(data)} as const
1315
export default data
14-
`
16+
`
17+
} catch (e) {
18+
dts = `
19+
declare const data = never
20+
export default data
21+
`
22+
}
1523
return tsModule.ScriptSnapshot.fromString(dts)
1624
}

0 commit comments

Comments
 (0)