Skip to content

Commit 5bbd9b2

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 5bbd9b2

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<<00cb2351bba6e33a8d2f129e6ccdf4c0>>
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, // 33aba12a
5990+
AccessibilityInfo, // 54271401
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, // c37376bf
5998+
ActivityIndicatorProps, // 9e338734
60055999
Alert, // 5bf12165
60066000
AlertButton, // bf1a3b60
60076001
AlertButtonStyle, // ec9fb242
60086002
AlertOptions, // a0cdac0f
60096003
AlertType, // 5ab91217
60106004
AndroidKeyboardEvent, // e03becc8
6011-
Animated, // 1a47480c
6005+
Animated, // 47b79675
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, // 780c86b3
60226016
BoxShadowValue, // b679703f
6023-
Button, // 869e5a89
6024-
ButtonProps, // 349967e6
6017+
Button, // ef9592c5
6018+
ButtonProps, // 314e63c6
60256019
Clipboard, // 41addb89
6026-
CodegenTypes, // 0b8108a8
6020+
CodegenTypes, // 449fadfa
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, // 94e81861
6037+
DrawerLayoutAndroidProps, // 9ff4484a
6038+
DrawerSlideEvent, // d175a538
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, // c05cd406
6053+
FlatListProps, // ccbb7cbf
6054+
FocusEvent, // 62f32376
60616055
FontVariant, // 7c7558bb
6062-
GestureResponderEvent, // f693e9a5
6063-
GestureResponderHandlers, // cc70e4cb
6056+
GestureResponderEvent, // e63debf2
6057+
GestureResponderHandlers, // 2b92c86d
60646058
Handle, // 2d65285d
6065-
HostComponent, // 16fccab5
6066-
HostInstance, // 9b5a9ec2
6059+
HostComponent, // 03bfd9f4
6060+
HostInstance, // ca179e31
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, // fd93f5d1
6066+
ImageBackground, // 4fe27d63
6067+
ImageBackgroundProps, // b2720e58
6068+
ImageErrorEvent, // 786fdfcc
6069+
ImageLoadEvent, // bef775c1
6070+
ImageProgressEventIOS, // 7aff2128
6071+
ImageProps, // 918d8ffe
60786072
ImagePropsAndroid, // 9fd9bcbb
6079-
ImagePropsBase, // 372b652b
6080-
ImagePropsIOS, // c4ae0c06
6073+
ImagePropsBase, // 085d3f57
6074+
ImagePropsIOS, // 872d46ca
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, // b97b3b72
60946088
KeyEvent, // 20fa4267
6095-
KeyUpEvent, // bc6bd87b
6089+
KeyUpEvent, // c0fda285
60966090
Keyboard, // 49414c97
6097-
KeyboardAvoidingView, // c8c29c8d
6098-
KeyboardAvoidingViewProps, // 4114f649
6091+
KeyboardAvoidingView, // 4cfb12da
6092+
KeyboardAvoidingViewProps, // 399d87a5
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, // 37529b47
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, // 22be095d
6118+
ModalBaseProps, // a278cadf
6119+
ModalProps, // 63861662
61266120
ModalPropsAndroid, // 515fb173
6127-
ModalPropsIOS, // 144bbc95
6128-
ModeChangeEvent, // a5e9864f
6129-
MouseEvent, // fdce82bc
6121+
ModalPropsIOS, // ac424bbd
6122+
ModeChangeEvent, // 679fe81e
6123+
MouseEvent, // 8e5523a5
61306124
NativeAppEventEmitter, // 08d4c47d
61316125
NativeColorValue, // d2094c29
6132-
NativeComponentRegistry, // 21481a60
6126+
NativeComponentRegistry, // 616e1846
61336127
NativeDialogManagerAndroid, // 5be8497e
61346128
NativeEventEmitter, // 27f97c1a
61356129
NativeEventSubscription, // de3942e7
6136-
NativeMethods, // a2311987
6137-
NativeMethodsMixin, // a819ef55
6130+
NativeMethods, // 53965456
6131+
NativeMethodsMixin, // 263e85c9
61386132
NativeModules, // 4597cd36
6139-
NativeMouseEvent, // 558d45b0
6140-
NativePointerEvent, // f1763d80
6133+
NativeMouseEvent, // 723e899b
6134+
NativePointerEvent, // e28e3782
61416135
NativeScrollEvent, // caad7f53
6142-
NativeSyntheticEvent, // 35855c4c
6136+
NativeSyntheticEvent, // cb87886b
61436137
NativeTouchEvent, // 59b676df
61446138
NativeUIEvent, // 44ac26ac
61456139
Networking, // bbc5be42
61466140
OpaqueColorValue, // 25f3fa5b
6147-
PanResponder, // 4320c1ba
6148-
PanResponderCallbacks, // ed54b109
6141+
PanResponder, // f95255ab
6142+
PanResponderCallbacks, // d54e3183
61496143
PanResponderGestureState, // 54baf558
6150-
PanResponderInstance, // 46b4629d
6144+
PanResponderInstance, // 957e6213
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, // 4af4b669
6155+
PressabilityConfig, // ad5b865f
6156+
PressabilityEventHandlers, // 28f81d78
6157+
Pressable, // 6a0232e2
61646158
PressableAndroidRippleConfig, // ee32eaca
6165-
PressableProps, // a9048420
6159+
PressableProps, // 2410d681
61666160
PressableStateCallbackType, // 9af36561
61676161
ProcessedColorValue, // 33f74304
6168-
ProgressBarAndroid, // 00fcd180
6169-
ProgressBarAndroidProps, // f59f8f03
6162+
ProgressBarAndroid, // a4af8a30
6163+
ProgressBarAndroidProps, // 07dcdf0d
61706164
PromiseTask, // 5102c862
61716165
PublicRootInstance, // 8040afd7
6172-
PublicTextInstance, // cd0d8f8d
6166+
PublicTextInstance, // 9fcf80fb
61736167
PushNotificationEventName, // 84e7e150
61746168
PushNotificationIOS, // b4d1fe78
61756169
PushNotificationPermissions, // c2e7ae4f
61766170
Rationale, // 5df1b1c1
61776171
ReactNativeVersion, // abd76827
6178-
RefreshControl, // ed67a3b2
6179-
RefreshControlProps, // bfc35644
6172+
RefreshControl, // 047bfe27
6173+
RefreshControlProps, // b50092cb
61806174
RefreshControlPropsAndroid, // 99f64c97
61816175
RefreshControlPropsIOS, // 72a36381
61826176
Registry, // 6c39216d
6183-
ResponderSyntheticEvent, // fb10247c
6177+
ResponderSyntheticEvent, // adf32caa
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, // cb3671f3
61926186
ScaledSize, // 07e417c7
6193-
ScrollEvent, // 5d529218
6194-
ScrollResponderType, // 197f0107
6187+
ScrollEvent, // 759fc8e1
6188+
ScrollResponderType, // 316d87b4
61956189
ScrollToLocationParamsType, // d7ecdad1
6196-
ScrollView, // 938178e6
6197-
ScrollViewImperativeMethods, // 27f6b917
6198-
ScrollViewProps, // d5d9f043
6190+
ScrollView, // 1051f16e
6191+
ScrollViewImperativeMethods, // c8dcbb4a
6192+
ScrollViewProps, // 3b182fce
61996193
ScrollViewPropsAndroid, // 44210553
6200-
ScrollViewPropsIOS, // b34b696c
6194+
ScrollViewPropsIOS, // 60c9a301
62016195
ScrollViewScrollToOptions, // 3313411e
62026196
SectionBase, // b376bddc
6203-
SectionList, // 6b202d76
6197+
SectionList, // 7f74e8c2
62046198
SectionListData, // 119baf83
6205-
SectionListProps, // 6bdbf0ef
6199+
SectionListProps, // f38d74b2
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, // 51333910
6219+
SwitchChangeEvent, // 8634990d
6220+
SwitchProps, // 73fbe487
62276221
Systrace, // 626d178c
62286222
TVViewPropsIOS, // 330ce7b5
62296223
TargetedEvent, // 16e98910
62306224
TaskProvider, // 266dedf2
6231-
Text, // 608149e8
6225+
Text, // 1e6955ef
62326226
TextContentType, // 239b3ecc
6233-
TextInput, // 3b7016bb
6227+
TextInput, // 1962fa97
62346228
TextInputAndroidProps, // 3f09ce49
6235-
TextInputChangeEvent, // 3ab11bb4
6236-
TextInputContentSizeChangeEvent, // f71f8571
6237-
TextInputEndEditingEvent, // e5f70633
6238-
TextInputFocusEvent, // 020507e6
6229+
TextInputChangeEvent, // 9e0264a8
6230+
TextInputContentSizeChangeEvent, // c0485b00
6231+
TextInputEndEditingEvent, // 5bab0db2
6232+
TextInputFocusEvent, // acd57d4f
62396233
TextInputIOSProps, // 0d05a855
6240-
TextInputKeyPressEvent, // 3924ad9b
6241-
TextInputProps, // 96c07405
6242-
TextInputSelectionChangeEvent, // d4d10630
6243-
TextInputSubmitEditingEvent, // 22885c31
6244-
TextLayoutEvent, // 73ab173e
6245-
TextProps, // 4c29419c
6234+
TextInputKeyPressEvent, // 3e9cd7e9
6235+
TextInputProps, // 719dad29
6236+
TextInputSelectionChangeEvent, // f4aee983
6237+
TextInputSubmitEditingEvent, // 69f5aed4
6238+
TextLayoutEvent, // 44ce8450
6239+
TextProps, // c5c6ea95
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, // 761abfef
6243+
TouchableHighlight, // c83e68c2
6244+
TouchableHighlightProps, // e1dcb561
6245+
TouchableNativeFeedback, // 44c0e01f
6246+
TouchableNativeFeedbackProps, // 3b815822
6247+
TouchableOpacity, // 2047870f
6248+
TouchableOpacityProps, // e24c059e
6249+
TouchableWithoutFeedback, // 989607ab
6250+
TouchableWithoutFeedbackProps, // d6aa3eec
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, // d70ecdb5
6258+
ViewProps, // ee6b9e68
6259+
ViewPropsAndroid, // 5f51df6e
62666260
ViewPropsIOS, // 58ee19bf
62676261
ViewStyle, // 00a0f8fb
62686262
VirtualViewMode, // 6be59722
62696263
VirtualizedList, // 68c7345e
6270-
VirtualizedListProps, // 9453ce86
6264+
VirtualizedListProps, // 037e96db
62716265
VirtualizedSectionList, // 9fd9cd61
6272-
VirtualizedSectionListProps, // 7a993da5
6266+
VirtualizedSectionListProps, // 6d45e684
62736267
WrapperComponentProvider, // 9cf3844c
62746268
codegenNativeCommands, // 628a7c0a
6275-
codegenNativeComponent, // 2baac257
6269+
codegenNativeComponent, // 2121cbfd
62766270
findNodeHandle, // 93f80214
62776271
processColor, // 6e877698
62786272
registerCallableModule, // 839c8cfe
6279-
requireNativeComponent, // 7f7f105a
6273+
requireNativeComponent, // 319187c5
62806274
useAnimatedColor, // e3511f81
62816275
useAnimatedValue, // b18adb63
62826276
useAnimatedValueXY, // c7ee2332
62836277
useColorScheme, // d585efdb
6284-
usePressability, // b4e21b46
6278+
usePressability, // 60593cad
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)