Commit Graph
896 Commits
Author SHA1 Message Date
Marco Wang 92c32780f1 Transform $ReadOnlyArray to ReadonlyArray 18/n (#55152)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55152

We are transforming the following utility types to be more consistent with typescript and better AI integration:

* `$NonMaybeType` -> `NonNullable`
* `$ReadOnly` -> `Readonly`
* `$ReadOnlyArray` -> `ReadonlyArray`
* `$ReadOnlyMap` -> `ReadonlyMap`
* `$ReadOnlySet` -> `ReadonlySet`
* `$Keys` -> `keyof`
* `$Values` -> `Values`
* `mixed` -> `unknown`

See details in https://fb.workplace.com/groups/flowlang/permalink/1837907750148213/.

drop-conflicts

Command:

`js1 flow-runner codemod flow/transformUtilityType --legacy-type='$ReadOnlyArray'`

Reviewed By: SamChou19815

Differential Revision: D90424826

fbshipit-source-id: 207e1abebb50671e8eb2a7f79ecfeaf4569b5b3e
2026-01-13 21:59:05 -08:00
Marco Wang 7051a07c63 Transform $ReadOnlyArray to ReadonlyArray 17/n (#55109)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55109

We are transforming the following utility types to be more consistent with typescript and better AI integration:

* `$NonMaybeType` -> `NonNullable`
* `$ReadOnly` -> `Readonly`
* `$ReadOnlyArray` -> `ReadonlyArray`
* `$ReadOnlyMap` -> `ReadonlyMap`
* `$ReadOnlySet` -> `ReadonlySet`
* `$Keys` -> `keyof`
* `$Values` -> `Values`
* `mixed` -> `unknown`

See details in https://fb.workplace.com/groups/flowlang/permalink/1837907750148213/.

drop-conflicts

Command:

`js1 flow-runner codemod flow/transformUtilityType --legacy-type='$ReadOnlyArray'`

Reviewed By: SamChou19815

Differential Revision: D90402950

fbshipit-source-id: d338ad7997728d40457b1199c3bd5dcd245a39c3
2026-01-13 20:33:09 -08:00
George Zahariev 0d27aedb73 Future proof for unknown type annotation node (#55069)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55069

In the future this will parse as `UnknownTypeAnnotation` - future proof.

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D90226759

fbshipit-source-id: 2f9d819f6536366f670100166d0091686ac782f6
2026-01-07 12:02:02 -08:00
Marco Wang 41efc3b588 Transform $ReadOnly to Readonly 38/n (#55067)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55067

Differential Revision: D90146229

fbshipit-source-id: 62733ba51fd0c318140b7a76b499b1a7ac1f7853
2026-01-06 20:23:03 -08:00
Alan Lee 391fc3c04e Add default case to EventEmitterH generator switch statement (#54950)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54950

Adds a default case to the switch statement in GenerateEventEmitterH.js to fix
compiler warnings about unhandled enum values in upcoming diff

```
[info] buck-out/v2/gen/fbsource/xplat/js/react-native-github/__generate_event_emitter_h-FBReactNativeSpec__/6c08ec662a69b177/out/EventEmitters.h:178:5: error: 'switch' missing 'default' label [-Werror,-Wswitch-default]
[info]   178 |     switch (value) {
[info]       |     ^
[info] 1 error generated.
[info] [2025-12-17T13:42:51.990-08:00]
[info] [2025-12-17T13:42:51.990-08:00] Action sub-errors produced by error handlers:
[info] - [apple_cxx_error][switch_default] buck-out/v2/gen/fbsource/xplat/js/react-native-github/__generate_event_emitter_h-FBReactNativeSpec__/6c08ec662a69b177/out/EventEmitters.h:178:5 'switch' missing 'default' label [-Wswitch-default]
[info]   Hint: https://fburl.com/apple_build_errors/missing_switch_default_label
[info]
[info] BUILD FAILED
```

Changelog: [Internal]

Reviewed By: cipolleschi, christophpurrer

Differential Revision: D89513261

fbshipit-source-id: c584cd60b6c735f437138db0041d3e0de0015c60
2025-12-23 11:09:52 -08:00
Marco Wang 894a1f16ef Transform mixed to unknown in xplat/js (#54954)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54954

We are transforming the following utility types to be more consistent with typescript and better AI integration:

* `$NonMaybeType` -> `NonNullable`
* `$ReadOnly` -> `Readonly`
* `$ReadOnlyArray` -> `ReadonlyArray`
* `$ReadOnlyMap` -> `ReadonlyMap`
* `$ReadOnlySet` -> `ReadonlySet`
* `$Keys` -> `keyof`
* `$Values` -> `Values`
* `mixed` -> `unknown`

See details in https://fb.workplace.com/groups/flowlang/permalink/1837907750148213/.
drop-conflicts

Reviewed By: SamChou19815

Differential Revision: D89581744

fbshipit-source-id: 58a6c246629bbe4fb5c0af447dc002c48e10c342
2025-12-22 12:25:44 -08:00
Marco Wang 68b0c2a69c Fix the build for unknown annotation (#54941)
Summary:
Changelog: [Internal] support flow 'unknown' syntax

Pull Request resolved: https://github.com/facebook/react-native/pull/54941

`buck build --flagfile fbcode//mode/opt fbcode//cathode/modules/react/lib/tests:app_delegate_test` crashed with

```javascript
Buck build failed for this target, and is likely caused by your changes.
Error message:
[New Failure] Target failed to build.
Action failed: fbsource//xplat/js/RKJSModules/Libraries/CathodeMessaging:FBReactNativeCathodeMessagingSpec-flow-types-ota-safety (cfg:opt-linux-x86_64-fbcode-platform010-clang19-no-san#3224936a2623a72b) (genrule)
Remote command returned non-zero exit code 1
Remote action, reproduce with: `frecli cas download-action 0c073e461a3ae239aa7e24c8a99b39543d365414405d1be1caa2196d7f55a18e:148`
Stdout: <empty>
Stderr:
UnsupportedGenericParserError: Module NativeCathodeMessagingModuleCxx: Unrecognized generic type 'unknown' in NativeModule spec.
    at translateTypeAnnotation (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/flow/modules/index.js:154:23)
    at /re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/parsers-commons.js:343:7
    at guard (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/utils.js:50:14)
    at translateFunctionTypeAnnotation (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/parsers-commons.js:334:25)
    at emitFunction (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/parsers-primitives.js:149:3)
    at translateTypeAnnotation (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/flow/modules/index.js:236:16)
    at /re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/parsers-commons.js:343:7
    at guard (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/utils.js:50:14)
    at translateFunctionTypeAnnotation (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/parsers-commons.js:334:25)
    at buildPropertySchema (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/parsers-commons.js:461:5)
    at /re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/parsers-commons.js:845:16
    at guard (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/utils.js:50:14)
    at /re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/parsers-commons.js:825:12
    at Array.map (<anonymous>)
    at buildModuleSchema (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/parsers-commons.js:811:3)
    at /re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/parsers-commons.js:583:9
    at guard (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/utils.js:50:14)
    at buildSchemaFromConfigType (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/parsers-commons.js:582:24)
    at buildSchema (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/parsers-commons.js:648:10)
    at FlowParser.parseString (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/react-native/codegen/src/parsers/flow/parser.js:131:12)
    at getSchemasForFiles (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/fb-tools/flow-schema/schema/getSchemasForFiles.js:101:51)
    at TypegenSchemaBuilder.addHackyInputsForReactNativeOnly (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/fb-tools/flow-schema/schema/TypegenSchema.js:94:5)
    at createTypegenSchema (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/fb-tools/flow-schema/commands/ota-safety.js:158:42)
    at Object.handler (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/fb-tools/flow-schema/commands/ota-safety.js:222:25)
    at /re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/yargs/build/index.cjs:1:8993
    at j (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/yargs/build/index.cjs:1:4956)
    at _.handleValidationAndGetResult (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/yargs/build/index.cjs:1:8962)
    at _.applyMiddlewareAndGetResult (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/yargs/build/index.cjs:1:9604)
    at _.runCommand (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/yargs/build/index.cjs:1:7231)
    at [runYargsParserAndExecuteCommands] (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/yargs/build/index.cjs:1:58544)
    at te.parse (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/node_modules/yargs/build/index.cjs:1:40483)
    at run (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/fb-tools/flow-schema/index.js:22:3)
    at Object.<anonymous> (/re_cwd/buck-out/v2/gen/fbsource/xplat/js/tools/flow-schema/__flow-schema__bin_build__/0a63598ffadb2c1e/out/flow-schema__bin_build.zip/fb-tools/flow-schema/index.js:42:1)
    at Module._compile (node:internal/modules/cjs/loader:1730:14)
    at Object..js (node:internal/modules/cjs/loader:1895:10)
    at Module.load (node:internal/modules/cjs/loader:1465:32)
    at Function._load (node:internal/modules/cjs/loader:1282:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5)
    at Object.run (/re_cwd/buck-out/v2/gen/fbsource/xplat/third-party/node/node-zip/__module__/84c2dad32661840d/out/run.js:202:10)
    at Object.<anonymous> (/re_cwd/buck-out/v2/gen/fbsource/xplat/third-party/node/node-zip/__module__/84c2dad32661840d/out/run.js:210:11)
    at Module._compile (node:internal/modules/cjs/loader:1730:14)
    at Object..js (node:internal/modules/cjs/loader:1895:10)
    at Module.load (node:internal/modules/cjs/loader:1465:32)
    at Function._load (node:internal/modules/cjs/loader:1282:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24) {
  nodes: [
    {
      type: 'GenericTypeAnnotation',
      loc: [Object],
      id: [Object],
      typeParameters: null,
      range: [Array]
    }
  ]
}
```

Fixing it in this diff

Reviewed By: SamChou19815

Differential Revision: D89519620

fbshipit-source-id: 5adcc305e9a7c2277122ccf3f446e0e5488fedae
2025-12-18 23:44:16 -08:00
Marco Wang a6b76c0c51 Support Readonly in react-native-codegen (#54925)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54925

The lint is triggered in D89415612. Not sure what those file do but it seems a good fix

Changelog: [General][Added] Support parsing `Readonly` for the new Flow utility types

Reviewed By: SamChou19815

Differential Revision: D89418629

fbshipit-source-id: 34a2776711155dbd52046d55af18104e2eb32322
2025-12-17 18:45:46 -08:00
Marco Wang 3bf7a09ecb Support ReadonlyArray in react-native-codegen (#54924)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54924

The lint is triggered in D89415612. Not sure what those file do but it seems a good fix

Changelog: [General][Added] Support parsing `ReadonlyArray` for the new Flow utility types

Reviewed By: SamChou19815

Differential Revision: D89418033

fbshipit-source-id: ef227b344a693ec47dea86bbf34e0af17bad25fd
2025-12-17 18:45:46 -08:00
Pieter De Baets d25af38453 Fix backwards-compat for ModuleConstants<::Builder> (#54919)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54919

Add a new `ResultT` to codegen and some C++ trickery so that `ModuleConstants<Type::Builder>` is equal to ModuleConstants<Type> and existing overrides of the module spec remain compatible.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D89373357

fbshipit-source-id: ac192e99e424a829668722722cf0c374172de48b
2025-12-17 11:21:29 -08:00
Pieter De Baets 2abbd47d1b Fix type of constantsToExport arg (#54718)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54718

The cast in `constantsToExport` is unnecessary if we actually use the right type here, without the `Builder` suffix.

Not a breaking change, since Objective-C seemingly doesn't enforce these parameter constraints.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D87980865

fbshipit-source-id: c9052e219fdf44d012583fcaa94b10b7c189b510
2025-12-16 05:37:01 -08:00
Nick Lefever dd390dbbef Add fixtures for optional object generation (#54727)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54727

See title

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D87843977

fbshipit-source-id: fdc8a1ecd60b46ab399150f3b38d7ef2ec83a7bf
2025-12-11 13:09:13 -08:00
Nick Lefever e581fa4f80 Implement optional object props generation (#54726)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54726

Add support for generating native optional object properties for custom types. This also updates the serialization of the custom type instances to only include properties that are defined on the object.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D87843979

fbshipit-source-id: c99179d7b48df62e836ab66dfad99f0723516af7
2025-12-11 13:09:13 -08:00
Nick Lefever 05599d0f66 Add fixtures for optional props generation (#54725)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54725

See title

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D87843980

fbshipit-source-id: a7e9c6034da57fe5a51904bd6b9e62276bf315b3
2025-12-11 13:09:13 -08:00
Nick Lefever 5c3bfda638 Add optional props generation support (#54724)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54724

Add support to codegen to generate native optional props for component properties that are defined as optional and have no default value.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D87843978

fbshipit-source-id: 9ad7436e2d518364b80b0e00ab7ec47eff476acd
2025-12-11 13:09:13 -08:00
Arushi Kesarwani 95cc1e7675 Add support for Unions in react-native-codegen & Compat Checker (#54489)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54489

Adding support for Unions in react-native-codegen & Compat Checker so that they can allow non-homogenous types and un-special casing `StringLiteralUnionTypeAnnotation`.

Changelog: [Internal]

**NOTE:** In case this needs to be reverted for any breakage to OTA Compat Checker v2, consider disabling it with D88289605 instead of reverting this change.

Reviewed By: RSNara

Differential Revision: D86501597

fbshipit-source-id: 6ea0d42c27f8f6b40fa607e7b671e599f25a94bc
2025-12-04 17:25:47 -08:00
Phil Pluckthun 41eace0093 Replace glob@^7.0.0 with tinyglobby@^0.2.15 (#54737)
Summary:
This replaces `glob@^7.0.0` with `tinyglobby@^0.2.15`. `glob@7` has been deprecated for a while and some versions after had security notices released for them. The plan is to backport this PR to `0.81.x` and onwards.

> [!NOTE]
> This is a stopgap solution until `fs.glob` becomes generally available with the EOL of Node v20

Succeeds:
- https://github.com/facebook/react-native/issues/54669
- https://github.com/facebook/react-native/issues/48875

## Changelog:

[GENERAL] [SECURITY] - Replace `glob@^7.0.0` with `tinyglobby@^0.2.15`

Pull Request resolved: https://github.com/facebook/react-native/pull/54737

Test Plan:
- Ran all modified commands manually and `pod install in `rn-tester`
- NOTE: `ios-prebuild`-related scripts haven't been run manually yet

Reviewed By: robhogan

Differential Revision: D88069145

Pulled By: huntie

fbshipit-source-id: 0c455342a4c6d1d6605fd09fe47b418e5d751491
2025-12-03 05:45:48 -08:00
Arushi Kesarwani 2bbb104a4e Introduce the supported member types of Union (#54591)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54591

Following types will be supported in Union currently:

1. Number : NumberType + NumberLiteralType
2. Boolean : BooleanType + BooleanLiteralType
3. String : StringType + StringLiteralType
4. Object: NativeModuleObjectType

These are the only ones that exist today as per :

https://docs.google.com/document/d/1pTBMOEIov5n5-0L9z925XPvGX1YxlmI6n6FJvd0oXtE/edit?tab=t.0#heading=h.fhe5py9plytd

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D87384995

fbshipit-source-id: 39e63fa3670343bc4063d8aa45a004671380a640
2025-11-20 18:00:53 -08:00
Arushi Kesarwani 2d22fed85c Introduce BooleanLiteralTypeAnnotation (#54590)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54590

Introduce `BooleanLiteralTypeAnnotation` in Flow & TypeScript to match the existing `StringLiteralTypeAnnotation` & `NumberLiteralTypeAnnotation` since Unions will be supporting Booleans along with String & Number

Changelog: [Internal]

Reviewed By: elicwhite

Differential Revision: D87384473

fbshipit-source-id: 6b8265914c7884ac99ae69e8992bc9dc6a9e52bc
2025-11-20 18:00:53 -08:00
Arushi Kesarwani 1d9d3ae4a4 Rename NativeModuleNumberLiteralTypeAnnotation & NativeModuleStringLiteralTypeAnnotation in TS (#54588)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54588

`NativeModuleNumberLiteralTypeAnnotation` -> `NumberLiteralTypeAnnotation` & `NativeModuleStringLiteralTypeAnnotation` -> `StringLiteralType` in TypeScript just as they already exist in Flow here:

https://www.internalfb.com/code/fbsource/[9b248afa0cd5548b81dd44f1042b230e6069432b]/xplat/js/react-native-github/packages/react-native-codegen/src/CodegenSchema.js?lines=41-53

Changelog: [Internal]

Reviewed By: elicwhite

Differential Revision: D87375511

fbshipit-source-id: c35afff132c2efa20ce1c45dc23ef2c64c91613c
2025-11-19 22:30:28 -08:00
Arushi Kesarwani b99c69a194 Introduce generic UnionTypeAnnotation (#54587)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54587

Adding the generic type T UnionTypeAnnotation. This will be used later to create Unions of types String, Number & Boolean.

Changelog: [Internal]

Reviewed By: elicwhite

Differential Revision: D87374445

fbshipit-source-id: 7844f969111af14e42d2b57891e4c0935a0dce53
2025-11-19 22:30:28 -08:00
Arushi Kesarwani f5e27e48a8 Adding NumberTypeAnnotation to Codegen Schema (#54586)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54586

Adding NumberTypeAnnotation to the Codegen Schema in order to obtain parity with String & Boolean which will be the Union types

Changelog: [Internal]

Reviewed By: elicwhite

Differential Revision: D87374063

fbshipit-source-id: aa17f13736075ea753b078e0f9ee3c0d24eec534
2025-11-19 22:30:28 -08:00
Nolan O'Brien 4bf8204391 Address -Wswitch-default issues (#54580)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54580

Changelog: [iOS] [Fixed] - Fix undefined behavior for values outside of enum range in generated `switch` methods in Objective-C.

Differential Revision: D87282978

fbshipit-source-id: 12b74e0525d30fcc0ff4f9d8e84c930d923cce5a
2025-11-18 08:55:32 -08:00
Mike Hardy abd3bfb5c9 Forward port away from deprecated React.ElementRef to React.ComponentRef (#54274)
Summary:
React v19 deprecated React.ElementRef and recommends using React.ComponentRef

This appears to work just fine, with no other changes other than the type, with the exception of the Codegen phase which makes no allowance for ComponentRef during parsing

I altered the typescript and flow parsers to accept the new ComponentRef as well as the old ElementRef

- Fixes https://github.com/facebook/react-native/issues/54272

## Changelog:

[INTERNAL][DEPRECATED] - use React.ComponentRef in codegen in place of React.ElementRef

Pull Request resolved: https://github.com/facebook/react-native/pull/54274

Test Plan: This is mostly checked in jest tests, I updated the fixtures to send ComponentRef through, and I updated the snapshots to expect a message that indicates either ElementRef or ComponentRef are expected

Reviewed By: javache

Differential Revision: D85556329

Pulled By: cipolleschi

fbshipit-source-id: 0ca4e3929743746da0bde1bfb0e05500db0594f7
2025-11-10 10:58:44 -08:00
Christoph Purrer c7a6935587 Default init custom C++ TM struct properties (#54391)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54391

Changelog: [Internal][Fixed] Default init custom C++ TM struct properties

Right now we don't do it and produce code as:
```
template <typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
struct NativeEditableObjectModulePropertyVal {
  P0 classOrList;
  P1 commonFields;
  P2 desc;
  P3 isDefault;
  P4 isSet;
  P5 scriptValue;
  P6 value;
  bool operator==(const NativeEditableObjectModulePropertyVal &other) const {
    return classOrList == other.classOrList && commonFields == other.commonFields && desc == other.desc && isDefault == other.isDefault && isSet == other.isSet && scriptValue == other.scriptValue && value == other.value;
  }
};
```

Now we do:
```
template <typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
struct NativeEditableObjectModulePropertyVal {
  P0 classOrList{};
  P1 commonFields{};
  P2 desc{};
  P3 isDefault{};
  P4 isSet{};
  P5 scriptValue{};
  P6 value{};
  bool operator==(const NativeEditableObjectModulePropertyVal &other) const {
    return classOrList == other.classOrList && commonFields == other.commonFields && desc == other.desc && isDefault == other.isDefault && isSet == other.isSet && scriptValue == other.scriptValue && value == other.value;
  }
};
```

Reviewed By: sbuggay, lenaic

Differential Revision: D86142954

fbshipit-source-id: 989e81c55b1fad7e1e58ea89461f064772143c9d
2025-11-04 04:49:44 -08:00
Christoph Purrer 0fd24c75a1 Simplify C++ TM base classes (#54059)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54059

Changelog: [Internal]

Right now for a simple spec as
```
import type {CodegenTypes, TurboModule} from 'react-native';

import {TurboModuleRegistry} from 'react-native';

export type ScreenshotManagerOptions = CodegenTypes.UnsafeObject;

export interface Spec extends TurboModule {
  +getConstants: () => {};
  takeScreenshot(
    id: string,
    options: ScreenshotManagerOptions,
  ): Promise<string>;
}

const NativeModule = TurboModuleRegistry.get<Spec>('ScreenshotManager');
export function takeScreenshot(
  id: string,
  options: ScreenshotManagerOptions,
): Promise<string> {
  if (NativeModule != null) {
    return NativeModule.takeScreenshot(id, options);
  }
  return Promise.reject();
}
```

we generate **TWO** `facebook::react::TurboModule` sub classes (`NativeScreenshotManagerCxxSpecJSI` and `NativeScreenshotManagerCxxSpec`) to construct ONE C++ TM.

In particular header
```
#pragma once

#include <ReactCommon/TurboModule.h>
#include <react/bridging/Bridging.h>

namespace facebook::react {

class JSI_EXPORT NativeScreenshotManagerCxxSpecJSI : public TurboModule {
 protected:
  NativeScreenshotManagerCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);

 public:
  virtual jsi::Object getConstants(jsi::Runtime& rt) = 0;
  virtual jsi::Value
  takeScreenshot(jsi::Runtime& rt, jsi::String id, jsi::Object options) = 0;
};

template <typename T>
class JSI_EXPORT NativeScreenshotManagerCxxSpec : public TurboModule {
 public:
  jsi::Value create(jsi::Runtime& rt, const jsi::PropNameID& propName)
      override {
    return delegate_.create(rt, propName);
  }

  std::vector<jsi::PropNameID> getPropertyNames(
      jsi::Runtime& runtime) override {
    return delegate_.getPropertyNames(runtime);
  }

  static constexpr std::string_view kModuleName = "ScreenshotManager";

 protected:
  NativeScreenshotManagerCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
      : TurboModule(
            std::string{NativeScreenshotManagerCxxSpec::kModuleName},
            jsInvoker),
        delegate_(reinterpret_cast<T*>(this), jsInvoker) {}

 private:
  class Delegate : public NativeScreenshotManagerCxxSpecJSI {
   public:
    Delegate(T* instance, std::shared_ptr<CallInvoker> jsInvoker)
        : NativeScreenshotManagerCxxSpecJSI(std::move(jsInvoker)),
          instance_(instance) {}

    jsi::Object getConstants(jsi::Runtime& rt) override {
      static_assert(
          bridging::getParameterCount(&T::getConstants) == 1,
          "Expected getConstants(...) to have 1 parameters");

      return bridging::callFromJs<jsi::Object>(
          rt, &T::getConstants, jsInvoker_, instance_);
    }
    jsi::Value takeScreenshot(
        jsi::Runtime& rt,
        jsi::String id,
        jsi::Object options) override {
      static_assert(
          bridging::getParameterCount(&T::takeScreenshot) == 3,
          "Expected takeScreenshot(...) to have 3 parameters");

      return bridging::callFromJs<jsi::Value>(
          rt,
          &T::takeScreenshot,
          jsInvoker_,
          instance_,
          std::move(id),
          std::move(options));
    }

   private:
    friend class NativeScreenshotManagerCxxSpec;
    T* instance_;
  };

  Delegate delegate_;
};

} // namespace facebook::react
```
and cpp
```
#include "AppSpecsJSI.h"

namespace facebook::react {

static jsi::Value __hostFunction_NativeScreenshotManagerCxxSpecJSI_getConstants(
    jsi::Runtime& rt,
    TurboModule& turboModule,
    const jsi::Value* args,
    size_t count) {
  return static_cast<NativeScreenshotManagerCxxSpecJSI*>(&turboModule)
      ->getConstants(rt);
}

static jsi::Value
__hostFunction_NativeScreenshotManagerCxxSpecJSI_takeScreenshot(
    jsi::Runtime& rt,
    TurboModule& turboModule,
    const jsi::Value* args,
    size_t count) {
  return static_cast<NativeScreenshotManagerCxxSpecJSI*>(&turboModule)
      ->takeScreenshot(
          rt,
          count <= 0 ? throw jsi::JSError(
                           rt, "Expected argument in position 0 to be passed")
                     : args[0].asString(rt),
          count <= 1 ? throw jsi::JSError(
                           rt, "Expected argument in position 1 to be passed")
                     : args[1].asObject(rt));
}

NativeScreenshotManagerCxxSpecJSI::NativeScreenshotManagerCxxSpecJSI(
    std::shared_ptr<CallInvoker> jsInvoker)
    : TurboModule("ScreenshotManager", jsInvoker) {
  methodMap_["getConstants"] = MethodMetadata{
      0, __hostFunction_NativeScreenshotManagerCxxSpecJSI_getConstants};
  methodMap_["takeScreenshot"] = MethodMetadata{
      2, __hostFunction_NativeScreenshotManagerCxxSpecJSI_takeScreenshot};
}

} // namespace facebook::react
```

The goal of this change is to simplify that and only have **ONE** `facebook::react::TurboModule` base class for a concrete Cxx TM as this header

```
/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#pragma once

template <typename T>
class JSI_EXPORT NativeScreenshotManagerCxxSpec : public TurboModule {
public:
  static constexpr std::string_view kModuleName = "ScreenshotManager";

protected:
  NativeScreenshotManagerCxxSpec(std::shared_ptr<CallInvoker> jsInvoker) : TurboModule(std::string{NativeScreenshotManagerCxxSpec::kModuleName}, jsInvoker) {
    methodMap_["getConstants"] = MethodMetadata {.argCount = 0, .invoker = __getConstants};
    methodMap_["takeScreenshot"] = MethodMetadata {.argCount = 2, .invoker = __takeScreenshot};
  }

private:
  static jsi::Value __getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* /*args*/, size_t /*count*/) {
    static_assert(
      bridging::getParameterCount(&T::getConstants) == 1,
      "Expected getConstants(...) to have 1 parameters");
    return bridging::callFromJs<jsi::Object>(rt, &T::getConstants,  static_cast<NativeScreenshotManagerCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule));
  }

  static jsi::Value __takeScreenshot(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
    static_assert(
      bridging::getParameterCount(&T::takeScreenshot) == 3,
      "Expected takeScreenshot(...) to have 3 parameters");
    return bridging::callFromJs<jsi::Value>(rt, &T::takeScreenshot,  static_cast<NativeScreenshotManagerCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
      count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
      count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asObject(rt));
  }
};
```

This reduces the generated code from 101 lines to 31 - **REDUCTION of 2/3**

Reviewed By: javache

Differential Revision: D83810977

fbshipit-source-id: 6d0c0271846c8544399c7050b7331b0180cbbadf
2025-10-13 20:21:32 -07:00
Sam Zhou 5c369aa34c Add annotations to fix future natural inference errors in xplat/js: 6/n (#53894)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53894

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D83000736

fbshipit-source-id: 3ba5c59d9b2f7b967c0dccd24a73056430153bdc
2025-09-22 21:55:34 -07:00
Tom Scallon 4308185b64 Allow EventEmitters to be reported as optional (#53804)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53804

## Changelog:

[General] [Fixed] - Allow `EventEmitter`s to be optional (for push safety)

Reviewed By: javache

Differential Revision: D82509571

fbshipit-source-id: 801a22b10b2709968009527130cfa890d30a4f3a
2025-09-16 08:59:12 -07:00
Marco Wang da9136f587 Turn on null strict comparison check for xplat js (#53379)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53379

X-link: https://github.com/facebook/react/pull/34240

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D80648362

fbshipit-source-id: cc47ae207f29a3ddb68bc0e029b8773f89503c52
2025-08-21 16:46:23 -07:00
Marco Wang 8351a5d186 Pre-Suppress errors for xplat/js for general strict comparison in non-generated files (#53342)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53342

Commands

```
scripts/flow/tool add-comments --comment 'Error discovered during Constant Condition roll out. See https://fburl.com/workplace/4oq3zi07.' .
```
```
arc f
```

drop-conflicts

Reviewed By: SamChou19815

Differential Revision: D80487235

fbshipit-source-id: 9e7c1a2641ddc0da0400fa1aff598b112a0434d5
2025-08-19 01:09:22 -07:00
Sam Zhou cf664c65e2 Standardize subtyping error code into incompatible-type in react native and metro (#53312)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53312

Changelog: [Internal]

Reviewed By: jbrown215

Differential Revision: D80400976

fbshipit-source-id: 196af69c0b9621b2a2675b232406639773e04933
2025-08-18 09:04:31 -07:00
Sam Zhou 35bee1a857 Add annotations to fix future natural inference errors in xplat/js
Summary: Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D80207164

fbshipit-source-id: e9a786c83f89a97db8b383812767978c47d9536c
2025-08-13 18:15:27 -07:00
David Vacca 1a85185cfc Deprecate ShadowNodes on the codegen (#53184)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53184

Deprecate ShadowNodes on the codegen

changelog: [internal] internal

Reviewed By: shwanton

Differential Revision: D79911692

fbshipit-source-id: ad24488d186fd5b82c3953a75f52be03e4770cc2
2025-08-09 04:39:35 -07:00
Riccardo Cipolleschi e547f466ee Improve codegen to add getDebugProps to components (#53135)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53135

Our Codegenerated components are not generating code for `getDebugProps`. This change modifies Codegen to add those functions for all the codegen components.

## Changelog:
[General][Added] - Added getDebugProps to codegen

## Facebook:
`getDebugProps` are required by Fantom to write tests. However, we can't generate these function for third party components, because codegen can generate arbitrary structs and we don't have a generic `toString()` method that can be used or automatically generated by C++.

By generating this function only for Core Components, we can ensure that we can write Fantom tests without breaking all the users of React Native.

Reviewed By: rubennorte

Differential Revision: D79805145

fbshipit-source-id: 0e41c65fc30eaa886a05557ca233fb0a9cb18a71
2025-08-08 06:47:23 -07:00
Sam Zhou af1bcb6d44 Mass replace $FlowIgnore with $FlowFixMe in react-native (#53076)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53076

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D79672242

fbshipit-source-id: 560f057d8658ed602cf7241e584bade70d8f3a99
2025-08-05 15:44:41 -07:00
Sam Zhou 2c3a00b7b1 Use the prettier config at the root for react-native-codegen (#52746)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52746

The config is needed for build, so I renamed it. In this way, the formatting of js code in react-native repo will be consistently controlled by the prettier config in the root. This change will make prettier v3 upgrade easier.

Changelog: [Internal]

Reviewed By: pieterv

Differential Revision: D78700564

fbshipit-source-id: 392ed490bf814870f285c8372ff68b454e228802
2025-07-21 19:45:34 -07:00
Sam Zhou 976055e52b Add annotations or make things readonly to prepare for array literal soundness fix
Summary: Changelog: [Internal]

Reviewed By: abhinayrathore, marcoww6

Differential Revision: D78689934

fbshipit-source-id: f749c4a0a6c34c80f09e4aaa05200ff282151838
2025-07-21 15:13:17 -07:00
David Vacca c2f39cfdd8 Revert Refactor ViewManagerInterfaces codegen to generate kotlin classes (#52593)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52593

Revert Refactor ViewManagerInterfaces codegen to generate kotlin classes since commands are not respecting nullability

changelog: [internal] internal

Reviewed By: bvanderhoof

Differential Revision: D78308183

fbshipit-source-id: f3d8017d4bc6473deef0fd49c000543913905cd9
2025-07-14 21:22:21 -07:00
Pieter De Baets 2321ae17ea Cleanup react-native-codegen DEFS [reland] (#52506)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52506

* Re-enable tests
* Simplify logic to avoid bypasses for arc focus

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D78000411

fbshipit-source-id: e2960a9848ce27385da00214018e7996d7c27561
2025-07-14 07:42:12 -07:00
David Vacca 79ca9036d3 Refactor ViewManagerInterfaces codegen to generate kotlin classes (#52545)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52545

Pull Request resolved: https://github.com/facebook/react-native/pull/51735

This diff refactors the ViewManagerInterfaces codegen to generate kotlin classes,

As a consequence of this change, there are some ViewManagerInterfaces that have changed their APIs

## Changelog: [Android][Breaking] - Migrate ViewManagerInterfaces to kotlin. Some types in code generated ViewManagerInterfaces might differ. e.g. this will start enforcing nullability in parameters of viewManagerInterface methods (e.g. String commands parameters are not nullable, view params are not nullable in any method, etc)

Reviewed By: cortinico

Differential Revision: D78118738

fbshipit-source-id: cdd9e660e55397bd0936efce1c5aaf90c2946b7a
2025-07-13 19:18:26 -07:00
Adan Moreno eb61e6f783 Revert D77143018: Cleanup react-native-codegen DEFS
Differential Revision:
D77143018

Original commit changeset: 06ec43ce5149

Original Phabricator Diff: D77143018

fbshipit-source-id: cec53068f88548c4494da315914763beb6730573
2025-07-08 16:29:45 -07:00
Pieter De Baets 120a417320 Cleanup react-native-codegen DEFS (#52468)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52468

* Re-enable tests
* Simplify logic to avoid bypasses for arc focus

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D77143018

fbshipit-source-id: 06ec43ce5149a139db78d38630191b01bc520461
2025-07-08 04:53:51 -07:00
Nick Lefever 27723c70b7 Clean up prop diffing gen (#52436)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52436

Reordered the different property types in the switch/case to group similar outputs together.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D77799101

fbshipit-source-id: 5b7c6d188e9ffa0f1e41f44f82f438afeda04d74
2025-07-05 06:19:23 -07:00
Nicola Corti 2d0aa1a747 Revert Refactor ViewManagerInterfaces codegen to generate kotlin classes
Summary:
reverting Refactor ViewManagerInterfaces codegen to generate kotlin classes because of warning in OSS, we will reland after 0.81 cut

Changelog: [Android][Breaking] - Revert of Migrate ViewManagerInterfaces to kotlin. Some types in code generated ViewManagerInterfaces might differ. e.g. this will start enforcing nullability in parameters of viewManagerInterface methods (e.g. String commands parameters are not nullable, view params are not nullable in any method, etc)

Reviewed By: lenaic, mlord93

Differential Revision: D77759777

fbshipit-source-id: c24b216b231cdc53296d8c9fca8d789d80daa596
2025-07-04 02:48:42 -07:00
David Vacca 76ff1aa5c6 Refactor ViewManagerInterfaces codegen to generate kotlin classes (#51735)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51735

This diff refactors the ViewManagerInterfaces codegen to generate kotlin classes,

As a consequence of this change, there are some ViewManagerInterfaces that have changed their APIs

## Changelog: [Android][Breaking] - Migrate ViewManagerInterfaces to kotlin. Some types in code generated ViewManagerInterfaces might differ. e.g. this will start enforcing nullability in parameters of viewManagerInterface methods (e.g. String commands parameters are not nullable, view params are not nullable in any method, etc)

Reviewed By: javache

Differential Revision: D75719542

fbshipit-source-id: 7e9aa7ccc24e827bd7b6df72b3302e852932e731
2025-07-03 12:19:42 -07:00
Sam Zhou 505588b9aa Add annotations or make things readonly to prepare for object literal soundness fix in react-native (#52305)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52305

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D77386425

fbshipit-source-id: d69184abb1c8f7c516229aafe24dd418b5dd887e
2025-06-26 13:24:24 -07:00
Nick Lefever c6608685cb Mark prop diffing availability for codegen props (#52246)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52246

This diff adds the required override to codegen props to make the `FabricMountingManager` aware of the availability of a prop diffing implementation for native components using codegen props.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D77234066

fbshipit-source-id: 8e95628348f491c5ee08609bc7d7b3d30bc7151b
2025-06-25 18:28:22 -07:00
Nick Lefever 53ce247dbd Add codegen for MixedType diffing (#52266)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52266

Native components may use `MixedType` properties in rare cases to hold untyped data. This diff adds support for serializing and prop diffing these types of props so that all of the props and object fields would be included in prop diffing results.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D77307169

fbshipit-source-id: ae6b00207ef857c9cfa4bdf9c235972915410a29
2025-06-25 18:28:22 -07:00
Nick Lefever e441954c82 Add codegen for ArrayType diffing (#52244)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52244

The ArrayType props converts to std::vector. This prompted the need for `toDynamic(const T&)` conversion functions as this breaks to potential reliance on all type instances having a `toDynamic()` function available. This includes:
- array of arrays types
- array of objects types
- object with arrays

The ArrayType conversion uses the availability of the `toDynamic` conversion methods for all supported types to convert the values stored by the `std::vector` to `folly::dynamic` values to be stored on a `folly::dynamic::array`.

The diff removes unnecessary conversion methods implemented previously for the core components prop diffing. These are now handled by the generic `toDynamic(const std::vector<T>&)` conversion method.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D77234065

fbshipit-source-id: 97a3b175ff07fe4a6de3adb14ee6cb42db1a2cfe
2025-06-25 18:28:22 -07:00
Nick Lefever b50ad49a4d Add codegen for ObjectType diffing (#52243)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52243

Building on the availability of `toDynamic` conversion methods for all supported property types, this diff adds support for diffing of `ObjectType` props.

The template adds the generation of a default comparator for the generated C++ struct. The struct also gains a `toDynamic` conversion method that will convert each property of the object type to a `folly::dynamic` value.

Primitive types make use of the implicit conversion supported by `folly::dynamic`, all other types are converted using `toDynamic`.

The `toDynamic` logic is implemented as a method defined on the struct to avoid increased binary size when required multiple times by the prop diffing implementation.

The external `toDynamic` conversion function calls the struct method directly. This enables support for converting object types using object types within their props.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D77234064

fbshipit-source-id: 21deb3104303aa374fb65b969af57a6aca6db38c
2025-06-25 18:28:22 -07:00