From 4715bc3329ddd714a54120ca0c85a769835ef362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Wed, 15 Apr 2026 03:51:53 -0700 Subject: [PATCH] Strip computed properties in build-types transform Summary: Changelog: [internal] Update the `stripPrivateProperties` Flow transform to also remove computed properties and methods from type definitions. These are implementation details that should not be part of the public API. Previously only underscore-prefixed identifiers were stripped. Now `PropertyDefinition` and `MethodDefinition` nodes with `node.computed === true` are also removed. Differential Revision: D100969511 --- .../transforms/flow/stripPrivateProperties.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/js-api/build-types/transforms/flow/stripPrivateProperties.js b/scripts/js-api/build-types/transforms/flow/stripPrivateProperties.js index 0cde0f0f158a..656291410105 100644 --- a/scripts/js-api/build-types/transforms/flow/stripPrivateProperties.js +++ b/scripts/js-api/build-types/transforms/flow/stripPrivateProperties.js @@ -26,12 +26,18 @@ const visitors: TransformVisitor = context => ({ } }, PropertyDefinition(node): void { - if (node.key.type === 'Identifier' && node.key.name.startsWith('_')) { + if ( + node.computed === true || + (node.key.type === 'Identifier' && node.key.name.startsWith('_')) + ) { context.removeNode(node); } }, MethodDefinition(node): void { - if (node.key.type === 'Identifier' && node.key.name.startsWith('_')) { + if ( + node.computed === true || + (node.key.type === 'Identifier' && node.key.name.startsWith('_')) + ) { context.removeNode(node); } },