diff --git a/src/loader/babel.ts b/src/loader/babel.ts index c9fed99..4a4be2a 100644 --- a/src/loader/babel.ts +++ b/src/loader/babel.ts @@ -222,8 +222,8 @@ function clumpLines(lines: string[], delimiters = [" "], separator = " ") { while (lines.length > 0) { const line = lines.shift(); if ( - (line && !delimiters.includes(line[0]) && clumps[clumps.length - 1]) || - containsIncompleteCodeblock(clumps[clumps.length - 1]) + (line && !delimiters.includes(line[0]) && clumps.at(-1)) || + containsIncompleteCodeblock(clumps.at(-1)) ) { clumps[clumps.length - 1] += separator + line; } else { @@ -259,15 +259,18 @@ function parseJSDocs(input: string | string[]): Schema { if (firstTag >= 0) { const tags = clumpLines(lines.slice(firstTag), ["@"], "\n"); // eslint-disable-next-line unicorn/no-array-reduce - const typedefs = tags.reduce((typedefs, tag) => { - const { typedef, alias } = - tag.match(/@typedef\s+{(?[\S\s]+)} (?.*)/)?.groups || - {}; - if (typedef && alias) { - typedefs[typedef] = alias; - } - return typedefs; - }, {} as Record); + const typedefs = tags.reduce( + (typedefs, tag) => { + const { typedef, alias } = + tag.match(/@typedef\s+{(?[\S\s]+)} (?.*)/)?.groups || + {}; + if (typedef && alias) { + typedefs[typedef] = alias; + } + return typedefs; + }, + {} as Record + ); for (const tag of tags) { if (tag.startsWith("@type")) { const type = tag.match(/@type\s+{([\S\s]+)}/)?.[1]; diff --git a/src/schema.ts b/src/schema.ts index e7264b2..9333166 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -58,7 +58,7 @@ async function _resolveSchema( const schema: Schema = { type: getType(input), id: schemaId, - default: !ctx.ignoreDefaults ? safeInput : undefined, + default: ctx.ignoreDefaults ? undefined : safeInput, }; normalizeSchema(schema, { ignoreDefaults: ctx.ignoreDefaults }); diff --git a/src/utils.ts b/src/utils.ts index 987ea84..5327a33 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -170,6 +170,6 @@ export function getTypeDescriptor(type: string | JSType): TypeDescriptor { return { ...(isJSType(type) ? { type } : {}), tsType: type, - ...(markdownType !== type ? { markdownType } : {}), + ...(markdownType === type ? {} : { markdownType }), }; } diff --git a/web/components/markdown.vue b/web/components/markdown.vue index 39cc5a4..0a1103b 100644 --- a/web/components/markdown.vue +++ b/web/components/markdown.vue @@ -54,14 +54,26 @@ export default defineComponent({