Skip to content

Commit 1284960

Browse files
fix: experimental support in generate types and schema compilation (#36)
1 parent 2d6c903 commit 1284960

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

compile-to-definitions/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ const preprocessSchema = (schema, root = schema, path = []) => {
129129
schema.properties[key] = {
130130
description: result.description,
131131
deprecated: result.deprecated,
132+
experimental: result.experimental,
132133
anyOf: [property],
133134
};
134135
} else if (
@@ -140,6 +141,7 @@ const preprocessSchema = (schema, root = schema, path = []) => {
140141
schema.properties[key] = {
141142
description: property.description || result.description,
142143
deprecated: property.deprecated || result.deprecated,
144+
experimental: property.experimental || result.experimental,
143145
anyOf: property.oneOf,
144146
};
145147
preprocessSchema(schema.properties[key], root, [...path, key]);

generate-types/index.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,20 @@ const printError = (diagnostic) => {
633633
.getJsDocTags(checker)
634634
.filter((tag) => tag.name === "deprecated");
635635

636-
if (!commentText && deprecatedTags.length === 0) return "";
636+
const experimentalTags = symbol
637+
.getJsDocTags(checker)
638+
.filter((tag) => tag.name === "experimental");
639+
640+
if (
641+
!commentText &&
642+
deprecatedTags.length === 0 &&
643+
experimentalTags.length === 0
644+
) {
645+
return "";
646+
}
637647

638648
const lines = commentText ? commentText.split("\n") : [];
649+
639650
for (const tag of deprecatedTags) {
640651
const text = normalizeText(tag.text);
641652
if (text && !commentText) {
@@ -646,6 +657,16 @@ const printError = (diagnostic) => {
646657
}
647658
}
648659

660+
for (const tag of experimentalTags) {
661+
const text = normalizeText(tag.text);
662+
if (text && !commentText) {
663+
lines.push(...text.split("\n"));
664+
lines.push("@experimental");
665+
} else {
666+
lines.push(text ? `@experimental ${text}` : "@experimental");
667+
}
668+
}
669+
649670
return `\n/**\n${lines
650671
.map((line) => (line ? ` * ${line}` : " *"))
651672
.join("\n")}\n */\n`;

0 commit comments

Comments
 (0)