diff --git a/packages/react-native-codegen/BUCK b/packages/react-native-codegen/BUCK index 6fe3543e9ff..663916dc6d1 100644 --- a/packages/react-native-codegen/BUCK +++ b/packages/react-native-codegen/BUCK @@ -37,8 +37,8 @@ fb_native.genrule( name = "codegen_tests_schema", srcs = glob( [ - "**/e2e/__test_fixtures__/*NativeComponent.js", - "**/e2e/__test_fixtures__/Native*.js", + "**/e2e/__test_fixtures__/components/*NativeComponent.js", + "**/e2e/__test_fixtures__/modules/Native*.js", ], ), cmd = "$(exe fbsource//xplat/js/react-native-github/packages/react-native-codegen:write_to_json) $OUT $SRCS", diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/ArrayPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js similarity index 67% rename from packages/react-native-codegen/e2e/__test_fixtures__/ArrayPropsNativeComponent.js rename to packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js index 930868ebc61..60307e99353 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/ArrayPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js @@ -13,15 +13,15 @@ import type { PointValue, ColorValue, -} from '../../../../Libraries/StyleSheet/StyleSheetTypes'; -import type {ImageSource} from '../../../../Libraries/Image/ImageSource'; +} from '../../../../../Libraries/StyleSheet/StyleSheetTypes'; +import type {ImageSource} from '../../../../../Libraries/Image/ImageSource'; import type { Int32, Float, WithDefault, -} from '../../../../Libraries/Types/CodegenTypes'; -import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; +} from '../../../../../Libraries/Types/CodegenTypes'; +import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent'; type NativeProps = $ReadOnly<{| ...ViewProps, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/BooleanPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js similarity index 61% rename from packages/react-native-codegen/e2e/__test_fixtures__/BooleanPropNativeComponent.js rename to packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js index c0805edf14e..2c6ad0a837e 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/BooleanPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js @@ -10,9 +10,9 @@ 'use strict'; -import type {WithDefault} from '../../../../Libraries/Types/CodegenTypes'; -import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; +import type {WithDefault} from '../../../../../Libraries/Types/CodegenTypes'; +import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent'; type NativeProps = $ReadOnly<{| ...ViewProps, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/ColorPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js similarity index 59% rename from packages/react-native-codegen/e2e/__test_fixtures__/ColorPropNativeComponent.js rename to packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js index 08e6f858535..3850dcaf63c 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/ColorPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js @@ -10,9 +10,9 @@ 'use strict'; -import type {ColorValue} from '../../../../Libraries/StyleSheet/StyleSheetTypes'; -import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; +import type {ColorValue} from '../../../../../Libraries/StyleSheet/StyleSheetTypes'; +import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent'; type NativeProps = $ReadOnly<{| ...ViewProps, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/EnumPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js similarity index 63% rename from packages/react-native-codegen/e2e/__test_fixtures__/EnumPropNativeComponent.js rename to packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js index e9e691b7ad9..3d38f07385e 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/EnumPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js @@ -10,9 +10,9 @@ 'use strict'; -import type {WithDefault} from '../../../../Libraries/Types/CodegenTypes'; -import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; +import type {WithDefault} from '../../../../../Libraries/Types/CodegenTypes'; +import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent'; type NativeProps = $ReadOnly<{| ...ViewProps, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/EventNestedObjectPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js similarity index 74% rename from packages/react-native-codegen/e2e/__test_fixtures__/EventNestedObjectPropsNativeComponent.js rename to packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js index 5e1d68f6503..1a0f2030e39 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/EventNestedObjectPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js @@ -14,9 +14,9 @@ import type { Int32, BubblingEventHandler, WithDefault, -} from '../../../../Libraries/Types/CodegenTypes'; -import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; +} from '../../../../../Libraries/Types/CodegenTypes'; +import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent'; type OnChangeEvent = $ReadOnly<{| location: { diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/EventPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js similarity index 84% rename from packages/react-native-codegen/e2e/__test_fixtures__/EventPropsNativeComponent.js rename to packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js index 1ad260238c9..65193c341e9 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/EventPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js @@ -16,9 +16,9 @@ import type { BubblingEventHandler, DirectEventHandler, WithDefault, -} from '../../../../Libraries/Types/CodegenTypes'; -import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; +} from '../../../../../Libraries/Types/CodegenTypes'; +import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent'; type OnChangeEvent = $ReadOnly<{| value: boolean, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/FloatPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js similarity index 73% rename from packages/react-native-codegen/e2e/__test_fixtures__/FloatPropsNativeComponent.js rename to packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js index be0e18f1ee9..81e27ba526b 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/FloatPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js @@ -13,9 +13,9 @@ import type { WithDefault, Float, -} from '../../../../Libraries/Types/CodegenTypes'; -import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; +} from '../../../../../Libraries/Types/CodegenTypes'; +import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent'; type NativeProps = $ReadOnly<{| ...ViewProps, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/ImagePropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js similarity index 60% rename from packages/react-native-codegen/e2e/__test_fixtures__/ImagePropNativeComponent.js rename to packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js index 32f6549984f..cb6793910fc 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/ImagePropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js @@ -10,9 +10,9 @@ 'use strict'; -import type {ImageSource} from '../../../../Libraries/Image/ImageSource'; -import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; +import type {ImageSource} from '../../../../../Libraries/Image/ImageSource'; +import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent'; type NativeProps = $ReadOnly<{| ...ViewProps, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/IntegerPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js similarity index 69% rename from packages/react-native-codegen/e2e/__test_fixtures__/IntegerPropNativeComponent.js rename to packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js index e539db1d02f..b21576ffb7d 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/IntegerPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js @@ -13,9 +13,9 @@ import type { WithDefault, Int32, -} from '../../../../Libraries/Types/CodegenTypes'; -import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; +} from '../../../../../Libraries/Types/CodegenTypes'; +import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent'; type NativeProps = $ReadOnly<{| ...ViewProps, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/InterfaceOnlyNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js similarity index 73% rename from packages/react-native-codegen/e2e/__test_fixtures__/InterfaceOnlyNativeComponent.js rename to packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js index ec293197fb7..3bdce224efa 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/InterfaceOnlyNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js @@ -13,9 +13,9 @@ import type { BubblingEventHandler, WithDefault, -} from '../../../../Libraries/Types/CodegenTypes'; -import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; +} from '../../../../../Libraries/Types/CodegenTypes'; +import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent'; type NativeProps = $ReadOnly<{| ...ViewProps, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/MultiNativePropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js similarity index 62% rename from packages/react-native-codegen/e2e/__test_fixtures__/MultiNativePropNativeComponent.js rename to packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js index 04b75d30813..dc8bb46a34c 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/MultiNativePropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js @@ -13,10 +13,10 @@ import type { PointValue, ColorValue, -} from '../../../../Libraries/StyleSheet/StyleSheetTypes'; -import type {ImageSource} from '../../../../Libraries/Image/ImageSource'; -import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; +} from '../../../../../Libraries/StyleSheet/StyleSheetTypes'; +import type {ImageSource} from '../../../../../Libraries/Image/ImageSource'; +import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent'; type NativeProps = $ReadOnly<{| ...ViewProps, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/NoPropsNoEventsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js similarity index 68% rename from packages/react-native-codegen/e2e/__test_fixtures__/NoPropsNoEventsNativeComponent.js rename to packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js index a2b1bc60912..5d75b6e3b59 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/NoPropsNoEventsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js @@ -10,8 +10,8 @@ 'use strict'; -import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; +import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent'; type NativeProps = $ReadOnly<{| ...ViewProps, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/PointPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js similarity index 60% rename from packages/react-native-codegen/e2e/__test_fixtures__/PointPropNativeComponent.js rename to packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js index d2c6d8f42dd..fdf3861e68a 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/PointPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js @@ -10,9 +10,9 @@ 'use strict'; -import type {PointValue} from '../../../../Libraries/StyleSheet/StyleSheetTypes'; -import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; +import type {PointValue} from '../../../../../Libraries/StyleSheet/StyleSheetTypes'; +import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent'; type NativeProps = $ReadOnly<{| ...ViewProps, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/StringPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js similarity index 63% rename from packages/react-native-codegen/e2e/__test_fixtures__/StringPropNativeComponent.js rename to packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js index 02a4a08b58e..b15debb6f27 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/StringPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js @@ -10,9 +10,9 @@ 'use strict'; -import type {WithDefault} from '../../../../Libraries/Types/CodegenTypes'; -import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; +import type {WithDefault} from '../../../../../Libraries/Types/CodegenTypes'; +import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent'; type NativeProps = $ReadOnly<{| ...ViewProps, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeArrayTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeArrayTurboModule.js new file mode 100644 index 00000000000..bf8a330d297 --- /dev/null +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeArrayTurboModule.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ + +'use strict'; + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export type ArrayType = string; +type AnotherArray = Array; + +export interface Spec extends TurboModule { + +getArray: (a: Array) => Array; + +getArrayWithAlias: (a: AnotherArray, b: Array) => AnotherArray; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeBooleanTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeBooleanTurboModule.js new file mode 100644 index 00000000000..7b332af37a3 --- /dev/null +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeBooleanTurboModule.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ + +'use strict'; + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export type Boolean = boolean; +type AnotherBoolean = Boolean; + +export interface Spec extends TurboModule { + +getBoolean: (arg: boolean) => boolean; + +getBooleanWithAlias: (arg: Boolean) => AnotherBoolean; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeCallbackTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeCallbackTurboModule.js new file mode 100644 index 00000000000..3ad70c62f44 --- /dev/null +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeCallbackTurboModule.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ + +'use strict'; + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export type String = string; +type CB = (value: String) => void; + +export interface Spec extends TurboModule { + +getValueWithCallback: (callback: (value: string) => void) => void; + +getValueWithCallbackWithAlias: (c: CB) => void; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeNumberTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeNumberTurboModule.js new file mode 100644 index 00000000000..8b63fda9451 --- /dev/null +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeNumberTurboModule.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ + +'use strict'; + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export type Number = number; +type AnotherNumber = Number; + +export interface Spec extends TurboModule { + +getNumber: (arg: number) => number; + +getNumberWithAlias: (arg: Number) => AnotherNumber; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeObjectTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeObjectTurboModule.js new file mode 100644 index 00000000000..b2761cbecd5 --- /dev/null +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeObjectTurboModule.js @@ -0,0 +1,29 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ + +'use strict'; + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export type GenericObject = Object; +type AnotherGenericObject = GenericObject; + +export interface Spec extends TurboModule { + +getGenericObject: (arg: Object) => Object; + +getGenericObjectWithAlias: (arg: GenericObject) => AnotherGenericObject; + +getConstants: () => {| + const1: boolean, + const2: number, + const3: string, + |}; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativePromiseTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativePromiseTurboModule.js new file mode 100644 index 00000000000..79dbf9add85 --- /dev/null +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativePromiseTurboModule.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ + +'use strict'; + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export type String = string; +type AnotherPromise = Promise; + +export interface Spec extends TurboModule { + +getValueWithPromise: (error: boolean) => Promise; + +getValueWithPromiseWithAlias: (arg: String) => AnotherPromise; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/NativeSampleTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModule.js similarity index 100% rename from packages/react-native-codegen/e2e/__test_fixtures__/NativeSampleTurboModule.js rename to packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModule.js diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeStringTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeStringTurboModule.js new file mode 100644 index 00000000000..2369153a430 --- /dev/null +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeStringTurboModule.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ + +'use strict'; + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export type String = string; +type AnotherString = String; + +export interface Spec extends TurboModule { + +getString: (arg: string) => string; + +getStringWithAlias: (arg: String) => AnotherString; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule');