Skip to content

Commit fc331f3

Browse files
rubennortemeta-codesync[bot]
authored andcommitted
Strip computed properties in build-types transform (#56450)
Summary: Pull Request resolved: #56450 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. Reviewed By: huntie Differential Revision: D100969511 fbshipit-source-id: 7eb1dfde99b56e9c460d83f6b12b7c31c3b04c92
1 parent d823f5b commit fc331f3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

scripts/js-api/build-types/transforms/flow/stripPrivateProperties.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,18 @@ const visitors: TransformVisitor = context => ({
2626
}
2727
},
2828
PropertyDefinition(node): void {
29-
if (node.key.type === 'Identifier' && node.key.name.startsWith('_')) {
29+
if (
30+
node.computed === true ||
31+
(node.key.type === 'Identifier' && node.key.name.startsWith('_'))
32+
) {
3033
context.removeNode(node);
3134
}
3235
},
3336
MethodDefinition(node): void {
34-
if (node.key.type === 'Identifier' && node.key.name.startsWith('_')) {
37+
if (
38+
node.computed === true ||
39+
(node.key.type === 'Identifier' && node.key.name.startsWith('_'))
40+
) {
3541
context.removeNode(node);
3642
}
3743
},

0 commit comments

Comments
 (0)