From ea95b6622594900d4d0f54b586263b5617b2e32e Mon Sep 17 00:00:00 2001 From: Aviv Keller Date: Fri, 19 Dec 2025 18:23:41 -0500 Subject: [PATCH 1/5] fix(legacy-json): don't double-signature ctors --- src/generators/legacy-json/utils/parseList.mjs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/generators/legacy-json/utils/parseList.mjs b/src/generators/legacy-json/utils/parseList.mjs index 73c36237..d4d48033 100644 --- a/src/generators/legacy-json/utils/parseList.mjs +++ b/src/generators/legacy-json/utils/parseList.mjs @@ -94,7 +94,14 @@ export function parseList(section, nodes) { // Update the section based on its type and parsed values switch (section.type) { - case 'ctor': + case 'ctor': { + const signature = parseSignature(section.textRaw, values); + + Object.keys(signature).forEach(key => (section[key] ??= signature[key])); + + break; + } + case 'classMethod': case 'method': // For methods and constructors, parse and attach signatures From 4b87c4d3703f1bb69248b688f12a39405931dfe6 Mon Sep 17 00:00:00 2001 From: Aviv Keller Date: Fri, 19 Dec 2025 18:28:44 -0500 Subject: [PATCH 2/5] fixup! --- src/generators/legacy-json/utils/parseList.mjs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/generators/legacy-json/utils/parseList.mjs b/src/generators/legacy-json/utils/parseList.mjs index d4d48033..be8ba38e 100644 --- a/src/generators/legacy-json/utils/parseList.mjs +++ b/src/generators/legacy-json/utils/parseList.mjs @@ -94,13 +94,10 @@ export function parseList(section, nodes) { // Update the section based on its type and parsed values switch (section.type) { - case 'ctor': { - const signature = parseSignature(section.textRaw, values); - - Object.keys(signature).forEach(key => (section[key] ??= signature[key])); - + case 'ctor': + // Constructors are their own signatures + Object.assign(section, parseSignature(section.textRaw, values)); break; - } case 'classMethod': case 'method': From 5e17d0c36ee58b53c0ef0c2fc8d2f13b5ff8338d Mon Sep 17 00:00:00 2001 From: Aviv Keller Date: Fri, 19 Dec 2025 18:35:11 -0500 Subject: [PATCH 3/5] fixup! --- src/generators/legacy-json/utils/parseList.mjs | 5 +++-- src/utils/generators.mjs | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/generators/legacy-json/utils/parseList.mjs b/src/generators/legacy-json/utils/parseList.mjs index be8ba38e..adf66bf4 100644 --- a/src/generators/legacy-json/utils/parseList.mjs +++ b/src/generators/legacy-json/utils/parseList.mjs @@ -5,6 +5,7 @@ import { TYPE_EXPRESSION, } from '../constants.mjs'; import parseSignature from './parseSignature.mjs'; +import { leftHandAssign } from '../../../utils/generators.mjs'; import createQueries from '../../../utils/queries/index.mjs'; import { transformNodesToString } from '../../../utils/unist.mjs'; @@ -96,7 +97,7 @@ export function parseList(section, nodes) { switch (section.type) { case 'ctor': // Constructors are their own signatures - Object.assign(section, parseSignature(section.textRaw, values)); + leftHandAssign(section, parseSignature(section.textRaw, values)); break; case 'classMethod': @@ -110,7 +111,7 @@ export function parseList(section, nodes) { if (values.length) { const { type, ...rest } = values[0]; section.type = type; - Object.assign(section, rest); + leftHandAssign(section, rest); section.textRaw = `\`${section.name}\` ${section.textRaw}`; } break; diff --git a/src/utils/generators.mjs b/src/utils/generators.mjs index f169a9fc..ddaae088 100644 --- a/src/utils/generators.mjs +++ b/src/utils/generators.mjs @@ -96,3 +96,16 @@ export const sortChanges = (changes, key = 'version') => { return compare(coerceSemVer(aVersion), coerceSemVer(bVersion)); }); }; + +/** + * Assigns properties from one or more source objects to the target object + * **without overwriting existing keys** in the target. + * + * Similar to `Object.assign`, but preserves the target's existing keys. + * The target object is mutated in place. + * + * @param {Object} target - The object to assign properties to. + * @param {Object} source - The source object + */ +export const leftHandAssign = (target, source) => + Object.keys(source).forEach(k => k in target || (target[k] = source[k])); From 62a388c15edfcc7a808fc472dfefef92f3d55e03 Mon Sep 17 00:00:00 2001 From: Aviv Keller Date: Fri, 19 Dec 2025 18:39:27 -0500 Subject: [PATCH 4/5] fixup! --- src/generators/jsx-ast/utils/__tests__/buildBarProps.test.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/generators/jsx-ast/utils/__tests__/buildBarProps.test.mjs b/src/generators/jsx-ast/utils/__tests__/buildBarProps.test.mjs index 0c1d8f89..145777b3 100644 --- a/src/generators/jsx-ast/utils/__tests__/buildBarProps.test.mjs +++ b/src/generators/jsx-ast/utils/__tests__/buildBarProps.test.mjs @@ -13,6 +13,7 @@ mock.module('../../../../utils/generators.mjs', { { version: '18.0.0', isLts: true, isCurrent: false }, { version: '19.0.0', isLts: false, isCurrent: true }, ], + leftHandAssign: Object.assign, getVersionFromSemVer: version => version.split('.')[0], getVersionURL: (version, api) => `/api/${version}/${api}`, }, From eaaaac758c26ab13377deb171b3f6f805cd7f84c Mon Sep 17 00:00:00 2001 From: Aviv Keller Date: Fri, 19 Dec 2025 18:43:36 -0500 Subject: [PATCH 5/5] fixup! --- src/generators/legacy-json/utils/parseList.mjs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/generators/legacy-json/utils/parseList.mjs b/src/generators/legacy-json/utils/parseList.mjs index adf66bf4..6f62bf66 100644 --- a/src/generators/legacy-json/utils/parseList.mjs +++ b/src/generators/legacy-json/utils/parseList.mjs @@ -109,10 +109,7 @@ export function parseList(section, nodes) { case 'property': // For properties, update type and other details if values exist if (values.length) { - const { type, ...rest } = values[0]; - section.type = type; - leftHandAssign(section, rest); - section.textRaw = `\`${section.name}\` ${section.textRaw}`; + leftHandAssign(section, values[0]); } break;