mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Strip computed properties in build-types transform (#56450)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
1 parent
d823f5b1cc
commit
fc331f3883
1 file changed
+8
-2
@@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user