Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions compile-to-definitions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const preprocessSchema = (schema, root = schema, path = []) => {
}
schema.properties[key] = {
description: result.description,
deprecated: result.deprecated,
anyOf: [property],
};
} else if (
Expand All @@ -128,6 +129,7 @@ const preprocessSchema = (schema, root = schema, path = []) => {
const result = resolvePath(root, property.oneOf[0].$ref);
schema.properties[key] = {
description: property.description || result.description,
deprecated: property.deprecated || result.deprecated,
anyOf: property.oneOf,
};
preprocessSchema(schema.properties[key], root, [...path, key]);
Expand Down
34 changes: 28 additions & 6 deletions generate-types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,12 +621,34 @@ const printError = (diagnostic) => {
*/
const getDocumentation = (symbol) => {
if (!symbol) return "";
const comments = symbol.getDocumentationComment(checker);
if (comments.length === 0) return "";
return `\n/**\n * ${comments
.map((c) => c.text)
.join("")
.replace(/\n+/g, "\n * ")}\n */\n`;
const normalizeText = (parts) =>
ts
.displayPartsToString(parts || [])
.replace(/\r\n?/g, "\n")
.replace(/\n+/g, "\n")
.trim();

let commentText = normalizeText(symbol.getDocumentationComment(checker));
const deprecatedTags = symbol
.getJsDocTags(checker)
.filter((tag) => tag.name === "deprecated");

if (!commentText && deprecatedTags.length === 0) return "";

const lines = commentText ? commentText.split("\n") : [];
for (const tag of deprecatedTags) {
const text = normalizeText(tag.text);
if (text && !commentText) {
lines.push(...text.split("\n"));
lines.push("@deprecated");
} else {
lines.push(text ? `@deprecated ${text}` : "@deprecated");
}
}

return `\n/**\n${lines
.map((line) => (line ? ` * ${line}` : " *"))
.join("\n")}\n */\n`;
};

/**
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
"ajv": "^8.1.0",
"commondir": "^1.0.1",
"glob": "^7.1.6",
"json-schema-to-typescript": "^9.1.1",
"json-schema-to-typescript": "^15.0.4",
"terser": "^5.32.0",
"yargs": "^16.1.1"
}
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
1 change: 1 addition & 0 deletions precompile-schemas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const schemas = glob.sync(schemasGlob, { cwd: root, absolute: true });
const EXCLUDED_PROPERTIES = [
"title",
"description",
"deprecated",
"cli",
"implements",
"tsType",
Expand Down
Loading