Skip to content

Commit

Permalink
Parse defaultCompilerOptions provided to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
vilicvane committed May 9, 2023
1 parent b6e7393 commit 41ff0ce
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/twoslash-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { join, dirname } from "path"
import remarkShikiTwoslash from "remark-shiki-twoslash"
import { basename, extname, sep } from "path"
import { tmpdir } from "os"
import ts from "typescript"

export const canConvert = (path) => {
const usable = [".md", ".ts", ".js", ".tsx", ".jsx"]
Expand Down Expand Up @@ -90,6 +91,14 @@ async function renderMarkdown(args) {
const settings = getSettingsFromMarkdown(fileContent, from) || {}
const markdownAST = remark().parse(fileContent)

if (settings.defaultCompilerOptions) {
const {options} = ts.convertCompilerOptionsFromJson(settings.defaultCompilerOptions, ".")
settings.defaultCompilerOptions = {
...settings.defaultCompilerOptions,
...options,
}
}

try {
// @ts-ignore
await remarkShikiTwoslash.default(settings)(markdownAST)
Expand Down

0 comments on commit 41ff0ce

Please sign in to comment.