Skip to content

Commit 2decca5

Browse files
huntiefacebook-github-bot
authored andcommitted
Hide ReactNativeElement constructor from public API (#57028)
Summary: Mark `ReactNativeElement` as non-user-constructible in the generated TypeScript definitions by selectively stripping the constructor on this type. **Motivation** - Correctness — like web DOM elements (`HTMLElement`, etc.), `ReactNativeElement` instances are created by the React Native runtime, not in user space. - Reduce public API surface (in particular, since this is also aliased to the `HostInstance` type). **Changes** - Adds a new `build-types omit-constructor` directive and corresponding `build-types` post-transform. - Applies directive to `ReactNativeElement`. - Also extracts shared `build-types` directive helpers into `transforms/typescript/utils/buildDirectives.js`. Changelog: [Internal] Differential Revision: D107119545
1 parent 7f396d1 commit 2decca5

7 files changed

Lines changed: 317 additions & 158 deletions

File tree

packages/react-native/ReactNativeApi.d.ts

Lines changed: 101 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<a438af540f18c77572f05cef9481b7a6>>
7+
* @generated SignedSource<<e611913bdbeb40cc0b2c4fd5b78b0aef>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -4047,12 +4047,6 @@ declare class ReactNativeElement_default
40474047
implements NativeMethods
40484048
{
40494049
blur(): void
4050-
constructor(
4051-
tag: number,
4052-
viewConfig: ViewConfig,
4053-
instanceHandle: InstanceHandle,
4054-
ownerDocument: ReactNativeDocument_default,
4055-
)
40564050
focus(): void
40574051
measure(callback: MeasureOnSuccessCallback): void
40584052
measureInWindow(callback: MeasureInWindowOnSuccessCallback): void
@@ -5992,23 +5986,23 @@ declare type WrapperComponentProvider = (
59925986
appParameters: Object,
59935987
) => React.ComponentType<any>
59945988
export {
5995-
AccessibilityActionEvent, // 5c5928b9
5996-
AccessibilityInfo, // 539eb4b3
5989+
AccessibilityActionEvent, // cd397533
5990+
AccessibilityInfo, // 294aa95c
59975991
AccessibilityProps, // 5a2836fc
59985992
AccessibilityRole, // f2f2e066
59995993
AccessibilityState, // b0c2b3f7
60005994
AccessibilityValue, // cf8bcb74
60015995
ActionSheetIOS, // b558559e
60025996
ActionSheetIOSOptions, // 1756eb5a
6003-
ActivityIndicator, // f06b0687
6004-
ActivityIndicatorProps, // 5e976856
5997+
ActivityIndicator, // fea7955e
5998+
ActivityIndicatorProps, // d33f5896
60055999
Alert, // 5bf12165
60066000
AlertButton, // bf1a3b60
60076001
AlertButtonStyle, // ec9fb242
60086002
AlertOptions, // a0cdac0f
60096003
AlertType, // 5ab91217
60106004
AndroidKeyboardEvent, // e03becc8
6011-
Animated, // 1a47480c
6005+
Animated, // ee418763
60126006
AppConfig, // ce4209a7
60136007
AppRegistry, // 5edf0524
60146008
AppState, // 12012be5
@@ -6018,12 +6012,12 @@ export {
60186012
AutoCapitalize, // c0e857a0
60196013
BackHandler, // f139fc69
60206014
BackPressEventName, // 4620fb76
6021-
BlurEvent, // e6151a1f
6015+
BlurEvent, // acda2fa7
60226016
BoxShadowValue, // b679703f
6023-
Button, // 869e5a89
6024-
ButtonProps, // 349967e6
6017+
Button, // 4a37f7a6
6018+
ButtonProps, // 2f6276ab
60256019
Clipboard, // 41addb89
6026-
CodegenTypes, // 0b8108a8
6020+
CodegenTypes, // 274af496
60276021
ColorSchemeName, // 6615edd6
60286022
ColorValue, // 98989a8f
60296023
ComponentProvider, // b5c60ddd
@@ -6039,9 +6033,9 @@ export {
60396033
DimensionsPayload, // 653bc26c
60406034
DisplayMetrics, // 1dc35cef
60416035
DisplayMetricsAndroid, // 872e62eb
6042-
DrawerLayoutAndroid, // eb4bcfa5
6043-
DrawerLayoutAndroidProps, // 1ddb208e
6044-
DrawerSlideEvent, // 0256d35a
6036+
DrawerLayoutAndroid, // 495e19fe
6037+
DrawerLayoutAndroidProps, // bbf9a4a6
6038+
DrawerSlideEvent, // ac9c5873
60456039
DropShadowValue, // e9df2606
60466040
DynamicColorIOS, // d96c228c
60476041
DynamicColorIOSTuple, // 023ce58e
@@ -6055,29 +6049,29 @@ export {
60556049
EventSubscription, // b8d084aa
60566050
ExtendedExceptionData, // 5a6ccf5a
60576051
FilterFunction, // bf24c0e3
6058-
FlatList, // e47faa4e
6059-
FlatListProps, // 22cacca0
6060-
FocusEvent, // 62fc1eb8
6052+
FlatList, // 6c8e0cd3
6053+
FlatListProps, // b89e1a36
6054+
FocusEvent, // 2f5267a2
60616055
FontVariant, // 7c7558bb
6062-
GestureResponderEvent, // f693e9a5
6063-
GestureResponderHandlers, // cc70e4cb
6056+
GestureResponderEvent, // 6d2adc14
6057+
GestureResponderHandlers, // d4c6b431
60646058
Handle, // 2d65285d
6065-
HostComponent, // 16fccab5
6066-
HostInstance, // 9b5a9ec2
6059+
HostComponent, // 8417c81a
6060+
HostInstance, // e8743de6
60676061
I18nManager, // f9870e00
60686062
IEventEmitter, // fbef6131
60696063
IOSKeyboardEvent, // e67bfe3a
60706064
IgnorePattern, // ec6f6ece
6071-
Image, // 1891541a
6072-
ImageBackground, // cf95f60b
6073-
ImageBackgroundProps, // c68c896d
6074-
ImageErrorEvent, // d3ee606e
6075-
ImageLoadEvent, // 6b547ea5
6076-
ImageProgressEventIOS, // 4c866a82
6077-
ImageProps, // 801d1e1c
6065+
Image, // cc4d5771
6066+
ImageBackground, // 71510b97
6067+
ImageBackgroundProps, // 9469cca5
6068+
ImageErrorEvent, // cc4ec63f
6069+
ImageLoadEvent, // e4ab897f
6070+
ImageProgressEventIOS, // 1b3108ea
6071+
ImageProps, // 9d07ff3e
60786072
ImagePropsAndroid, // 9fd9bcbb
6079-
ImagePropsBase, // 372b652b
6080-
ImagePropsIOS, // c4ae0c06
6073+
ImagePropsBase, // 820c59ac
6074+
ImagePropsIOS, // e257195a
60816075
ImageRequireSource, // 681d683b
60826076
ImageResolvedAssetSource, // f3060931
60836077
ImageSize, // 1c47cf88
@@ -6090,12 +6084,12 @@ export {
60906084
InputModeOptions, // 4e8581b9
60916085
Insets, // e7fe432a
60926086
InteractionManager, // c324d6e3
6093-
KeyDownEvent, // d4971b72
6087+
KeyDownEvent, // d43982a0
60946088
KeyEvent, // 20fa4267
6095-
KeyUpEvent, // bc6bd87b
6089+
KeyUpEvent, // 6e88850c
60966090
Keyboard, // 49414c97
6097-
KeyboardAvoidingView, // c8c29c8d
6098-
KeyboardAvoidingViewProps, // 4114f649
6091+
KeyboardAvoidingView, // 91bfca69
6092+
KeyboardAvoidingViewProps, // a57c4e92
60996093
KeyboardEvent, // c3f895d4
61006094
KeyboardEventEasing, // af4091c8
61016095
KeyboardEventName, // 59299ad6
@@ -6108,7 +6102,7 @@ export {
61086102
LayoutAnimationProperty, // 52995f01
61096103
LayoutAnimationType, // 2da0a29b
61106104
LayoutAnimationTypes, // 081b3bde
6111-
LayoutChangeEvent, // c388ba2b
6105+
LayoutChangeEvent, // 07f31e40
61126106
LayoutConformanceProps, // 055f03b8
61136107
LayoutRectangle, // 6601b294
61146108
Linking, // 9a6a174d
@@ -6120,34 +6114,34 @@ export {
61206114
MeasureInWindowOnSuccessCallback, // a285f598
61216115
MeasureLayoutOnSuccessCallback, // 3592502a
61226116
MeasureOnSuccessCallback, // 82824e59
6123-
Modal, // bdd9bb3f
6124-
ModalBaseProps, // 3cca97dc
6125-
ModalProps, // aa4211df
6117+
Modal, // e38bb16e
6118+
ModalBaseProps, // e6d20773
6119+
ModalProps, // 6d7ce288
61266120
ModalPropsAndroid, // 515fb173
6127-
ModalPropsIOS, // 144bbc95
6128-
ModeChangeEvent, // a5e9864f
6129-
MouseEvent, // fdce82bc
6121+
ModalPropsIOS, // 92c587ca
6122+
ModeChangeEvent, // cebaf08b
6123+
MouseEvent, // 8b172a2b
61306124
NativeAppEventEmitter, // 08d4c47d
61316125
NativeColorValue, // d2094c29
6132-
NativeComponentRegistry, // 21481a60
6126+
NativeComponentRegistry, // 7d971085
61336127
NativeDialogManagerAndroid, // 5be8497e
61346128
NativeEventEmitter, // 27f97c1a
61356129
NativeEventSubscription, // de3942e7
6136-
NativeMethods, // a2311987
6137-
NativeMethodsMixin, // a819ef55
6130+
NativeMethods, // 2aa4f8dc
6131+
NativeMethodsMixin, // 4570b7e0
61386132
NativeModules, // 4597cd36
6139-
NativeMouseEvent, // 558d45b0
6140-
NativePointerEvent, // f1763d80
6133+
NativeMouseEvent, // 34766845
6134+
NativePointerEvent, // 2acc483a
61416135
NativeScrollEvent, // caad7f53
6142-
NativeSyntheticEvent, // 35855c4c
6136+
NativeSyntheticEvent, // 21ba7467
61436137
NativeTouchEvent, // 59b676df
61446138
NativeUIEvent, // 44ac26ac
61456139
Networking, // bbc5be42
61466140
OpaqueColorValue, // 25f3fa5b
6147-
PanResponder, // 4320c1ba
6148-
PanResponderCallbacks, // ed54b109
6141+
PanResponder, // 33ea3f08
6142+
PanResponderCallbacks, // c53efe18
61496143
PanResponderGestureState, // 54baf558
6150-
PanResponderInstance, // 46b4629d
6144+
PanResponderInstance, // 5faad091
61516145
Permission, // 06473f4f
61526146
PermissionStatus, // 4b7de97b
61536147
PermissionsAndroid, // db2a401e
@@ -6157,52 +6151,52 @@ export {
61576151
PlatformOSType, // 0a17561e
61586152
PlatformSelectSpec, // 09ed7758
61596153
PointValue, // 69db075f
6160-
PointerEvent, // fe3989a1
6161-
PressabilityConfig, // 6dedcb61
6162-
PressabilityEventHandlers, // 3e6c0f56
6163-
Pressable, // 0241ba70
6154+
PointerEvent, // 7ebff673
6155+
PressabilityConfig, // 75dfc97f
6156+
PressabilityEventHandlers, // 0ae1e3bd
6157+
Pressable, // 38856d22
61646158
PressableAndroidRippleConfig, // ee32eaca
6165-
PressableProps, // a9048420
6159+
PressableProps, // ee168252
61666160
PressableStateCallbackType, // 9af36561
61676161
ProcessedColorValue, // 33f74304
6168-
ProgressBarAndroid, // 00fcd180
6169-
ProgressBarAndroidProps, // f59f8f03
6162+
ProgressBarAndroid, // 74634782
6163+
ProgressBarAndroidProps, // 1118c5ba
61706164
PromiseTask, // 5102c862
61716165
PublicRootInstance, // 8040afd7
6172-
PublicTextInstance, // cd0d8f8d
6166+
PublicTextInstance, // c35f1c78
61736167
PushNotificationEventName, // 84e7e150
61746168
PushNotificationIOS, // b4d1fe78
61756169
PushNotificationPermissions, // c2e7ae4f
61766170
Rationale, // 5df1b1c1
61776171
ReactNativeVersion, // abd76827
6178-
RefreshControl, // ed67a3b2
6179-
RefreshControlProps, // bfc35644
6172+
RefreshControl, // 4ad4cabb
6173+
RefreshControlProps, // fa64b7b5
61806174
RefreshControlPropsAndroid, // 99f64c97
61816175
RefreshControlPropsIOS, // 72a36381
61826176
Registry, // 6c39216d
6183-
ResponderSyntheticEvent, // fb10247c
6177+
ResponderSyntheticEvent, // 97b818a2
61846178
ReturnKeyTypeOptions, // afd47ba3
61856179
Role, // af7b889d
61866180
RootTag, // 3cd10504
61876181
RootTagContext, // 38bfc8f6
61886182
RootViewStyleProvider, // d4818465
61896183
Runnable, // 594dd93a
61906184
Runnables, // 4367c557
6191-
SafeAreaView, // a7cd92bb
6185+
SafeAreaView, // a6a09f08
61926186
ScaledSize, // 07e417c7
6193-
ScrollEvent, // 5d529218
6194-
ScrollResponderType, // 197f0107
6187+
ScrollEvent, // 5d4c42ac
6188+
ScrollResponderType, // ac611309
61956189
ScrollToLocationParamsType, // d7ecdad1
6196-
ScrollView, // 938178e6
6197-
ScrollViewImperativeMethods, // 27f6b917
6198-
ScrollViewProps, // d5d9f043
6190+
ScrollView, // 7004df06
6191+
ScrollViewImperativeMethods, // 4aae6e61
6192+
ScrollViewProps, // 579d84f3
61996193
ScrollViewPropsAndroid, // 44210553
6200-
ScrollViewPropsIOS, // b34b696c
6194+
ScrollViewPropsIOS, // b45f8013
62016195
ScrollViewScrollToOptions, // 3313411e
62026196
SectionBase, // b376bddc
6203-
SectionList, // 6b202d76
6197+
SectionList, // 9b9a8b6e
62046198
SectionListData, // 119baf83
6205-
SectionListProps, // 6bdbf0ef
6199+
SectionListProps, // 4210e506
62066200
SectionListRenderItem, // 1fad0435
62076201
SectionListRenderItemInfo, // 745e1992
62086202
Separators, // 6a45f7e3
@@ -6221,66 +6215,66 @@ export {
62216215
StyleProp, // fa0e9b4a
62226216
StyleSheet, // e77dd046
62236217
SubmitBehavior, // c4ddf490
6224-
Switch, // 015be3f7
6225-
SwitchChangeEvent, // 63e9c50b
6226-
SwitchProps, // 0dbf23ea
6218+
Switch, // 8a5dd325
6219+
SwitchChangeEvent, // 29e36f52
6220+
SwitchProps, // 9381f89d
62276221
Systrace, // 626d178c
62286222
TVViewPropsIOS, // 330ce7b5
62296223
TargetedEvent, // 16e98910
62306224
TaskProvider, // 266dedf2
6231-
Text, // 608149e8
6225+
Text, // 8b2957a7
62326226
TextContentType, // 239b3ecc
6233-
TextInput, // 3b7016bb
6227+
TextInput, // 0b608e71
62346228
TextInputAndroidProps, // 3f09ce49
6235-
TextInputChangeEvent, // 3ab11bb4
6236-
TextInputContentSizeChangeEvent, // f71f8571
6237-
TextInputEndEditingEvent, // e5f70633
6238-
TextInputFocusEvent, // 020507e6
6229+
TextInputChangeEvent, // 8ebeab3b
6230+
TextInputContentSizeChangeEvent, // 95a066bb
6231+
TextInputEndEditingEvent, // 3680ccf4
6232+
TextInputFocusEvent, // 45c2aa74
62396233
TextInputIOSProps, // 0d05a855
6240-
TextInputKeyPressEvent, // 3924ad9b
6241-
TextInputProps, // 96c07405
6242-
TextInputSelectionChangeEvent, // d4d10630
6243-
TextInputSubmitEditingEvent, // 22885c31
6244-
TextLayoutEvent, // 73ab173e
6245-
TextProps, // 4c29419c
6234+
TextInputKeyPressEvent, // c986943c
6235+
TextInputProps, // 8f74364f
6236+
TextInputSelectionChangeEvent, // 5f7906d5
6237+
TextInputSubmitEditingEvent, // e833130c
6238+
TextLayoutEvent, // 57140552
6239+
TextProps, // 7e9abf8b
62466240
TextStyle, // bb9b7a58
62476241
ToastAndroid, // 88a8969a
6248-
Touchable, // da3239ee
6249-
TouchableHighlight, // 49bbefe7
6250-
TouchableHighlightProps, // f14a1131
6251-
TouchableNativeFeedback, // d89b59a8
6252-
TouchableNativeFeedbackProps, // a88ade2e
6253-
TouchableOpacity, // 8d1b023b
6254-
TouchableOpacityProps, // 908e84b9
6255-
TouchableWithoutFeedback, // 71d446ec
6256-
TouchableWithoutFeedbackProps, // e0c1c566
6242+
Touchable, // 4aa582e2
6243+
TouchableHighlight, // 90d5cc9b
6244+
TouchableHighlightProps, // f673f0fa
6245+
TouchableNativeFeedback, // c900c4a5
6246+
TouchableNativeFeedbackProps, // 628d8b62
6247+
TouchableOpacity, // 9ea86e83
6248+
TouchableOpacityProps, // 5bfb00bf
6249+
TouchableWithoutFeedback, // 0809b337
6250+
TouchableWithoutFeedbackProps, // a66fa1d6
62576251
TransformsStyle, // 65e70f18
62586252
TurboModule, // dfe29706
62596253
TurboModuleRegistry, // 4ace6db2
62606254
UIManager, // a1a7cc01
62616255
UTFSequence, // ad625158
62626256
Vibration, // 31e4bbf8
6263-
View, // 234d8db5
6264-
ViewProps, // 6d644e8b
6265-
ViewPropsAndroid, // ac650c5c
6257+
View, // 8af5b18a
6258+
ViewProps, // 7ebf88bb
6259+
ViewPropsAndroid, // e377ec69
62666260
ViewPropsIOS, // 58ee19bf
62676261
ViewStyle, // 00a0f8fb
62686262
VirtualViewMode, // 6be59722
62696263
VirtualizedList, // 68c7345e
6270-
VirtualizedListProps, // 9453ce86
6264+
VirtualizedListProps, // 9487c00e
62716265
VirtualizedSectionList, // 9fd9cd61
6272-
VirtualizedSectionListProps, // 7a993da5
6266+
VirtualizedSectionListProps, // d88c2af1
62736267
WrapperComponentProvider, // 9cf3844c
62746268
codegenNativeCommands, // 628a7c0a
6275-
codegenNativeComponent, // 2baac257
6269+
codegenNativeComponent, // ffaf8efe
62766270
findNodeHandle, // 93f80214
62776271
processColor, // 6e877698
62786272
registerCallableModule, // 839c8cfe
6279-
requireNativeComponent, // 7f7f105a
6273+
requireNativeComponent, // 84ae9e06
62806274
useAnimatedColor, // e3511f81
62816275
useAnimatedValue, // b18adb63
62826276
useAnimatedValueXY, // c7ee2332
62836277
useColorScheme, // d585efdb
6284-
usePressability, // b4e21b46
6278+
usePressability, // d6ab8469
62856279
useWindowDimensions, // bb4b683f
62866280
}

packages/react-native/src/private/webapis/dom/nodes/ReactNativeElement.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const noop = () => {};
6767
// was slower than this method because the engine has to create an object than
6868
// we then discard to create a new one.
6969

70+
/** @build-types omit-constructor */
7071
class ReactNativeElement extends ReadOnlyElement implements NativeMethods {
7172
// These need to be accessible from `ReactFabricPublicInstanceUtils`.
7273
__nativeTag: number;

0 commit comments

Comments
 (0)