Skip to content

Commit 7959a63

Browse files
coadofacebook-github-bot
authored andcommitted
Migrate rn-tester codegen types imports to use root exported CodegenTypes namespace (#50976)
Summary: Pull Request resolved: #50976 This is the second part of the migration of `rn-tester` package to use root imports. In this diff the `CodegenTypes` namespace is used to define Codegen primitives. Changelog: [Internal] Reviewed By: huntie Differential Revision: D73780584 fbshipit-source-id: c13c2dfcfa4d023978a9463af1d2a3bf7b72476c
1 parent 9666a68 commit 7959a63

File tree

3 files changed

+18
-26
lines changed

3 files changed

+18
-26
lines changed

packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,20 @@
88
* @format
99
*/
1010

11-
import type {HostComponent, ViewProps} from 'react-native';
12-
import type {
13-
BubblingEventHandler,
14-
Double,
15-
Float,
16-
Int32,
17-
} from 'react-native/Libraries/Types/CodegenTypes';
11+
import type {CodegenTypes, HostComponent, ViewProps} from 'react-native';
1812

1913
import * as React from 'react';
2014
import {codegenNativeCommands, codegenNativeComponent} from 'react-native';
2115

2216
type Event = $ReadOnly<{
23-
values: $ReadOnlyArray<Int32>,
17+
values: $ReadOnlyArray<CodegenTypes.Int32>,
2418
boolValues: $ReadOnlyArray<boolean>,
25-
floats: $ReadOnlyArray<Float>,
26-
doubles: $ReadOnlyArray<Double>,
19+
floats: $ReadOnlyArray<CodegenTypes.Float>,
20+
doubles: $ReadOnlyArray<CodegenTypes.Double>,
2721
yesNos: $ReadOnlyArray<'yep' | 'nope'>,
2822
strings: $ReadOnlyArray<string>,
29-
latLons: $ReadOnlyArray<{lat: Double, lon: Double}>,
30-
multiArrays: $ReadOnlyArray<$ReadOnlyArray<Int32>>,
23+
latLons: $ReadOnlyArray<{lat: CodegenTypes.Double, lon: CodegenTypes.Double}>,
24+
multiArrays: $ReadOnlyArray<$ReadOnlyArray<CodegenTypes.Int32>>,
3125
}>;
3226

3327
type LegacyStyleEvent = $ReadOnly<{
@@ -36,12 +30,12 @@ type LegacyStyleEvent = $ReadOnly<{
3630

3731
type NativeProps = $ReadOnly<{
3832
...ViewProps,
39-
opacity?: Float,
40-
values: $ReadOnlyArray<Int32>,
33+
opacity?: CodegenTypes.Float,
34+
values: $ReadOnlyArray<CodegenTypes.Int32>,
4135

4236
// Events
43-
onIntArrayChanged?: ?BubblingEventHandler<Event>,
44-
onLegacyStyleEvent?: ?BubblingEventHandler<
37+
onIntArrayChanged?: ?CodegenTypes.BubblingEventHandler<Event>,
38+
onLegacyStyleEvent?: ?CodegenTypes.BubblingEventHandler<
4539
LegacyStyleEvent,
4640
'alternativeLegacyName',
4741
>,

packages/rn-tester/NativeCxxModuleExample/NativeCxxModuleExample.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
* @format
99
*/
1010

11-
import type {TurboModule} from 'react-native';
12-
import type {EventEmitter} from 'react-native/Libraries/Types/CodegenTypes';
11+
import type {CodegenTypes, TurboModule} from 'react-native';
1312

1413
import {TurboModuleRegistry} from 'react-native';
1514

@@ -77,11 +76,11 @@ export type CustomDeviceEvent = {
7776
};
7877

7978
export interface Spec extends TurboModule {
80-
+onPress: EventEmitter<void>;
81-
+onClick: EventEmitter<string>;
82-
+onChange: EventEmitter<ObjectStruct>;
83-
+onSubmit: EventEmitter<ObjectStruct[]>;
84-
+onEvent: EventEmitter<EnumNone>;
79+
+onPress: CodegenTypes.EventEmitter<void>;
80+
+onClick: CodegenTypes.EventEmitter<string>;
81+
+onChange: CodegenTypes.EventEmitter<ObjectStruct>;
82+
+onSubmit: CodegenTypes.EventEmitter<ObjectStruct[]>;
83+
+onEvent: CodegenTypes.EventEmitter<EnumNone>;
8584
+getArray: (arg: Array<ObjectStruct | null>) => Array<ObjectStruct | null>;
8685
+getBool: (arg: boolean) => boolean;
8786
+getConstants: () => ConstantsStruct;

packages/rn-tester/NativeModuleExample/NativeScreenshotManager.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
* @format
99
*/
1010

11-
import type {TurboModule} from 'react-native';
12-
import type {UnsafeObject} from 'react-native/Libraries/Types/CodegenTypes';
11+
import type {CodegenTypes, TurboModule} from 'react-native';
1312

1413
import {TurboModuleRegistry} from 'react-native';
1514

16-
export type ScreenshotManagerOptions = UnsafeObject;
15+
export type ScreenshotManagerOptions = CodegenTypes.UnsafeObject;
1716

1817
export interface Spec extends TurboModule {
1918
+getConstants: () => {};

0 commit comments

Comments
 (0)