From 48b3a310e15588dc3c8f77ed9b7043df2afe2c66 Mon Sep 17 00:00:00 2001 From: alexander-akait Date: Fri, 10 Apr 2026 17:07:33 +0300 Subject: [PATCH] fix: `experimental` support in generate types and schema compilation --- compile-to-definitions/index.js | 2 ++ generate-types/index.js | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/compile-to-definitions/index.js b/compile-to-definitions/index.js index 8388fdd..32cbe4d 100644 --- a/compile-to-definitions/index.js +++ b/compile-to-definitions/index.js @@ -129,6 +129,7 @@ const preprocessSchema = (schema, root = schema, path = []) => { schema.properties[key] = { description: result.description, deprecated: result.deprecated, + experimental: result.experimental, anyOf: [property], }; } else if ( @@ -140,6 +141,7 @@ const preprocessSchema = (schema, root = schema, path = []) => { schema.properties[key] = { description: property.description || result.description, deprecated: property.deprecated || result.deprecated, + experimental: property.experimental || result.experimental, anyOf: property.oneOf, }; preprocessSchema(schema.properties[key], root, [...path, key]); diff --git a/generate-types/index.js b/generate-types/index.js index c581bad..ac4a7e3 100644 --- a/generate-types/index.js +++ b/generate-types/index.js @@ -633,9 +633,20 @@ const printError = (diagnostic) => { .getJsDocTags(checker) .filter((tag) => tag.name === "deprecated"); - if (!commentText && deprecatedTags.length === 0) return ""; + const experimentalTags = symbol + .getJsDocTags(checker) + .filter((tag) => tag.name === "experimental"); + + if ( + !commentText && + deprecatedTags.length === 0 && + experimentalTags.length === 0 + ) { + return ""; + } const lines = commentText ? commentText.split("\n") : []; + for (const tag of deprecatedTags) { const text = normalizeText(tag.text); if (text && !commentText) { @@ -646,6 +657,16 @@ const printError = (diagnostic) => { } } + for (const tag of experimentalTags) { + const text = normalizeText(tag.text); + if (text && !commentText) { + lines.push(...text.split("\n")); + lines.push("@experimental"); + } else { + lines.push(text ? `@experimental ${text}` : "@experimental"); + } + } + return `\n/**\n${lines .map((line) => (line ? ` * ${line}` : " *")) .join("\n")}\n */\n`;