Commit Graph

1048 Commits

Author SHA1 Message Date
React Native Bot 84ebbb54f5 Release 0.80.0
#publish-packages-to-npm&latest
2025-06-12 15:27:37 +00:00
React Native Bot 6e8aa89830 Release 0.80.0-rc.5
#publish-packages-to-npm&next
2025-06-09 16:23:01 +00:00
React Native Bot dffb675e70 Release 0.80.0-rc.4
#publish-packages-to-npm&next
2025-06-02 16:25:27 +00:00
React Native Bot e7901a720b Release 0.80.0-rc.3
#publish-packages-to-npm&next
2025-05-26 15:55:04 +00:00
React Native Bot b35291cbb8 Release 0.80.0-rc.2
#publish-packages-to-npm&next
2025-05-19 18:06:14 +00:00
React Native Bot d2168e9415 Release 0.80.0-rc.1
#publish-packages-to-npm&next
2025-05-12 16:16:21 +00:00
React Native Bot d9c2857e59 Release 0.80.0-rc.0
#publish-packages-to-npm&next
2025-05-07 10:17:06 +00:00
Sam Zhou 88a04c530e Pre-suppress errors related to Object.assign
Summary:
The `Object.assign` support is [inherently unsound](https://github.com/facebook/flow/issues/3392), carries a lot of tech debt, and we want to error on them.

This diff pre-suppresses errors that will be added in the next version of Flow, to make the next release easier.

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D73963639

fbshipit-source-id: ebefc82c123588eb0b72ab48a24e45c42be33267
2025-04-30 19:44:58 -07:00
Jakub Grzywacz 4d7c4bd6e8 Fix ImageSource require (#50963)
Summary:
In react-native-svg, I found that the `Image` component stopped working starting with `react-native@0.79`. After some debugging, I traced the issue to the migration of `Libraries/Image` to the new export syntax (see https://github.com/facebook/react-native/commit/8783196ee540f8f78ce60ad20800338cc7645194). To fix this, I updated the import to match other requires, similar to https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js#L84.

## Changelog:

[GENERAL] [FIXED] - Fix codegen ImageSource require

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

Test Plan:
`validAttributes` process should be a function instead of object with a default property.

Before:
<img width="1041" alt="image" src="https://github.com/user-attachments/assets/9fbc9e9f-6c45-4b0b-adb8-2eb911676fe1" />

After:
<img width="1005" alt="image" src="https://github.com/user-attachments/assets/ee594103-90da-4917-8252-72f4ecfc28e1" />

Reviewed By: Abbondanzo

Differential Revision: D73778127

Pulled By: huntie

fbshipit-source-id: ae80c770e8e578794ae1356751f170ff955e1f5a
2025-04-28 10:30:21 -07:00
George Zahariev 6ad41f9a3f Update hermes-parser and related packages in xplat to 0.28.1 (#50803)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50803

Bump hermes-parser and related packages to [0.28.1](https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md).

Changelog: [internal]

Reviewed By: panagosg7

Differential Revision: D73242526

fbshipit-source-id: fbe0a233b4ae1315eb0e060c6338eb7156a5c6ea
2025-04-21 07:50:22 -07:00
Jakub Piasecki 86bede9c60 Update hermes-parser and related packages in fbsource to 0.28.0 (#50695)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50695

Bump hermes-parser and related packages to 0.28.0.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D72693713

fbshipit-source-id: f529b78a933ae7a6497f67f1f616c1acb95995c3
2025-04-15 03:56:39 -07:00
Tim Yung 68cad5d2d3 RN: Configure Hermes Parser for React 19 (#50377)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50377

Configures the Hermes Parser to target React 19, which changes components written with Component Syntax to stop generating `forwardRef` calls (because `ref` is now a prop).

Changelog:
[General][Changed] - Configured Hermes Parser to target React 19, resulting in Component Syntax no longer producing `forwardRef` calls.

Reviewed By: javache, SamChou19815

Differential Revision: D72070021

fbshipit-source-id: b891789d4ff1cbcb8eebea3525361ab14e628b51
2025-04-14 08:36:24 -07:00
Pieter De Baets 6e701ce080 Fix crash on arm32 when configuring eventEmitterCallback (#50592)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50592

For unclear reasons this is crashing on some devices when dereferencing the module ref. Instead we can just access the existing global_ref to the module instance and avoid any deallocation timing issues.

Also added some additional safeguards and validation against incorrect JNI invocations.

Changelog: [Android][Fixed] Fix crash when TurboModule event emitters are used on arm32

Reviewed By: cortinico

Differential Revision: D72716972

fbshipit-source-id: 3803329048d8388b3d30c9cb55a857e399569eea
2025-04-09 11:10:31 -07:00
Evghenii Nicolaev d3daabfe2b Revert D71805075: Update hermes-parser and related packages in fbsource to 0.27.0
Differential Revision:
D71805075

Original commit changeset: 685194c12ac0

Original Phabricator Diff: D71805075

fbshipit-source-id: b28f0f83ad8b4f4f6b5e62fdc9ff323af79c1d43
2025-04-01 03:45:23 -07:00
Alex Hunt f13c8a7417 Update hermes-parser and related packages in fbsource to 0.27.0 (#50241)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50241

Bump hermes-parser and related packages to [0.27.0](https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md).

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D71805075

fbshipit-source-id: 685194c12ac037f74cc4fd54eb0d777a74507727
2025-04-01 01:01:05 -07:00
Tim Yung e704f8ac2f RN/Metro: Set reactRuntimeTarget on Hermes Parser (#50339)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50339

Explicitly sets the default `reactRuntimeTarget` when invoking `require('hermes-parser').parse` so that it'll be easier to find these configurations when upgrading to `'19'`.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D72006705

fbshipit-source-id: 4994917152a2a4a767b871d4a36092c0c5391324
2025-03-28 08:02:09 -07:00
Sam Zhou cbd2ee55ef Eliminate $PropertyType and $ElementType in react-native (#50262)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50262

Prepare for their removal in Flow

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D71823860

fbshipit-source-id: e1e18424ae731cd323999316a7f3a5d42f4b5b91
2025-03-25 14:00:17 -07:00
Tim Yung 0448cf2567 RN: Support .fb Suffix in Native Codegen (#50140)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50140

Extends `react-native-codegen` to support the `.fb` filename suffix used to gate source code that is only relevant for Meta internal use cases.

Changelog:
[Internal]

Reviewed By: cipolleschi

Differential Revision: D70808462

fbshipit-source-id: a6772d6504f76724b8474df6799bc69a76a2f81b
2025-03-19 20:21:02 -07:00
Jakub Piasecki 5349b7c7b5 Update codegen to support namespaced types (#49950)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49950

Changelog: [GENERAL][CHANGED] - Changed `react-native-codegen` to support types under `CodegenTypes` namespace

## Summary

Currently, codegen relies on deep importing types under `react-native/Libraries/Types/CodegenTypes` to be properly type-checked. Updating codegen to support types under a single namespace will enable us to provide a single import from the package with access to all relevant types.

Reviewed By: huntie

Differential Revision: D70967809

fbshipit-source-id: 41241dcc51965f4243acd34e8b63475cb56ca67a
2025-03-17 07:26:17 -07:00
Arushi Kesarwani d8b0e050c4 Making RN Codegen generate ComponentDescriptors.cpp (#49939)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49939

Making RNCodegen.js generate the ComponentDesciptors.cpp and https://github.com/facebook/react-native/pull/42962 adds all entries, just missed this one.

Changelog:
[Android] [Fixed] - Fix RNCodegen.js for generating ComponentDescriptors.cpp

Reviewed By: shwanton

Differential Revision: D70925850

fbshipit-source-id: 2e2eae64f5371b0bc5a452d4bd0c9269e9253bb1
2025-03-12 15:44:46 -07:00
Alex Hunt e70961e05c Bump packages for next release (#49972)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49972

Follows the recent `0.79-stable` branch cut.

Changelog: [Internal] - Bump all packages to `0.80.0-main`

Reviewed By: cortinico

Differential Revision: D70976555

fbshipit-source-id: e81e4c45c6a510e114d02853c5bb90a715b7df8b
2025-03-12 05:11:16 -07:00
Phil Pluckthun b52f0d8391 chore(react-native-codegen): Remove fixtures and outdated transforms from build output (#49916)
Summary:
- Update ignore micromatch pattern to filter out `__test_fixtures__` from build output
- Remove `babel/plugin-transform-object-rest-spread`
- Remove `babel/plugin-transform-async-to-generator`
- Remove `babel/plugin-transform-destructuring`

The `package.json:engines:node` field is already set to `>=18` which makes the three Babel transforms that were removed redundant.

## Changelog:

[INTERNAL] [CHANGED] - Remove fixtures files and outdated Babel transforms from `react-native/codegen` build output

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

Test Plan: - Ran against Node 18

Reviewed By: robhogan

Differential Revision: D70885090

Pulled By: cortinico

fbshipit-source-id: 328b75a6031a7ca6a9b3ed170061ffb0a47d6d93
2025-03-10 05:44:32 -07:00
Phil Pluckthun 8f19201c5e refactor(react-native-codegen): Replace jscodeshift with @babel/core (#49641)
Summary:
`jscodeshift` is only used in one module (`src/generators/components/GenerateViewConfigJs.js`, but depends on a rather complex dependency chain and has a rather large maintenance burden relative to what it's used for and the value it adds in the codebase.

Since the `GenerateViewConfigJs` module creates simple templates, using `babel/core` (and implicitly `babel/template` and `babel/types`) is a lot simpler and changes little code. The only change this introduces to the output are formatting changes (`singleQuote` and `trailingCommas` options are discarded). The code is otherwise functionally identical.

## Changelog:

[INTERNAL] [CHANGED] - Drop jscodeshift dependency from react-native/codegen

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

Test Plan:
This was tested against a React Native build with the `react-native/babel-plugin-codegen` plugina active and using the snapshots in the repo itself. While the snapshots have changed in formatting, none of the outputs change the code's AST.

<details>
<summary>
Example output from <code>react-native/babel-plugin-codegen</code> to supplement the snapshot tests
</summary>

This is the example bundling output of `AndroidSwipeRefreshLayout`. This demonstrates that both the view config output and the `Commands` export continue to be generated correctly.

```js
var _interopRequireDefault = require(_dependencyMap[0]);
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.__INTERNAL_VIEW_CONFIG = exports.Commands = undefined;
var _codegenNativeCommands = _interopRequireDefault(require(_dependencyMap[1]));
var _codegenNativeComponent = _interopRequireDefault(require(_dependencyMap[2]));
var React = _interopRequireWildcard(require(_dependencyMap[3]));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var NativeComponentRegistry = require(_dependencyMap[4]);
var _require = require(_dependencyMap[5]),
  ConditionallyIgnoredEventHandlers = _require.ConditionallyIgnoredEventHandlers;
var _require2 = require(_dependencyMap[6]),
  dispatchCommand = _require2.dispatchCommand;
var nativeComponentName = 'AndroidSwipeRefreshLayout';
var __INTERNAL_VIEW_CONFIG = exports.__INTERNAL_VIEW_CONFIG = {
  uiViewClassName: "AndroidSwipeRefreshLayout",
  directEventTypes: {
    topRefresh: {
      registrationName: "onRefresh"
    }
  },
  validAttributes: {
    enabled: true,
    colors: {
      process: (req => 'default' in req ? req.default : req)(require(_dependencyMap[7]))
    },
    progressBackgroundColor: {
      process: require(_dependencyMap[8]).default
    },
    size: true,
    progressViewOffset: true,
    refreshing: true,
    ...ConditionallyIgnoredEventHandlers({
      onRefresh: true
    })
  }
};
var _default = exports.default = NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
var Commands = exports.Commands = {
  setNativeRefreshing(ref, value) {
    dispatchCommand(ref, "setNativeRefreshing", [value]);
  }
};
```

</details>

Reviewed By: yungsters

Differential Revision: D70580474

Pulled By: elicwhite

fbshipit-source-id: 85bc6578b685f19a1565ded8d7e56dc2a1ff1999
2025-03-05 14:06:46 -08:00
Nicola Corti c4c3d3bfbe Do not use $ in identifiers for event emitters. (#49792)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49792

This removes the `$` from the `event` and `payload` identifier inside codegen.
This is causing the `-Wdollar-in-identifier-extension` warning to fire.

As I'm looking into enabling `-Wall -Werror` for React Common, this should be addressed as well.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D70500543

fbshipit-source-id: c593680961b1b98561c3985f92ade5d6ba448ac9
2025-03-03 16:47:46 -08:00
Rubén Norte e630b2ca18 Create specific module in RN to define the types for host instances and host components that ReactNativeTypes defines (#49601)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49601

Changelog: [internal]

This creates a new module in React Native to define some of the types related to `HostInstance` that are currently defined in `ReactNativeTypes` (synced from the React repo).

We want to remove the types from `ReactNativeTypes` so this is a necessary initial step.

Reviewed By: huntie

Differential Revision: D69996010

fbshipit-source-id: 21cfed4c222e22332936e56aca895fe578809792
2025-02-24 05:32:43 -08:00
Iwo Plaza 2b30aa5cc8 Migrate Libraries/Utilities/differ/*.js to export syntax (#49332)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49332

## Motivation
Modernising the RN codebase to allow for modern Flow tooling to process it.

## This diff
- Migrates `Libraries/Utilities/differ/*.js` to use the export syntax.
- Updates deep-imports of these files to use `.default`
- Updates codegen with a compat layer
- Updates the current iteration of API snapshots (intended).

Changelog:
[General][Breaking] - Deep imports to `Libraries/Utilities/differ/...` with `require` syntax need to be appended with '.default'.

Reviewed By: yungsters

Differential Revision: D69467423

fbshipit-source-id: 2e58a0b9711e9bdf5ca907a5b2252584f6fec9bc
2025-02-12 05:30:20 -08:00
Pieter De Baets 9073817925 Add more test coverage for $ReadOnlyArray<UnsafeMixed> in component codegen (#49349)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49349

Follow-up on D69454101 to add more test coverage for `$ReadOnlyArray<UnsafeMixed>` as a component prop. The new type was missing from the CodegenSchema, which revealed some gaps in tests.

Changelog: [Internal]

Reviewed By: fabriziocucci

Differential Revision: D69488035

fbshipit-source-id: 19895e55e5ec4d89a790f1c388de9eea025a316c
2025-02-12 04:20:08 -08:00
Pieter De Baets abd7259de4 Allow UnsafeMixed as Array value in codegen (#49324)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49324

Provide Android component codegen a bit more flexibility by allowing `$ReadOnlyArray<UnsafeMixed>` and avoid casting in the view manager.

Changelog: [General][Added]

Reviewed By: fabriziocucci

Differential Revision: D69454101

fbshipit-source-id: c210647deffeb01b7db8aa07266e58c42acf14ba
2025-02-11 07:11:18 -08:00
Nick Gerleman 75edf3af50 CMake "react_render_" to "react_renderer_" (#49284)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49284

All of the CMake library names in the "renderer" directory use "render" for the name, missing the last two letters of the directory name.

eye_twitch

I don't think fixing that should be breaking, since 3p libraries need to rely on the merged library anyway, so let's fix that and find/replace all these.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D69338892

fbshipit-source-id: d3b306ad0ea191728dfbacf9e2aaa12b00caa619
2025-02-10 14:32:26 -08:00
Iwo Plaza 4101a2f0b6 Add compat layer for react-native-codegen and processColorArray (#49063)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49063

## Motivation
Modernising the RN codebase to allow for modern Flow tooling to process it.

## This diff
- Updates react-native-codegen to generate ViewConfigs that are compatible with react-native both before and after the export syntax migration.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D68894819

fbshipit-source-id: fca46c1b91c15e22f1e1128ce8621c05341e2fe6
2025-01-30 07:16:54 -08:00
Iwo Plaza 156ee5bee7 Migrate StyleSheet/processColorArray.js to use export syntax (#48905)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48905

## Motivation
Modernising the react-native codebase to allow for ingestion by modern Flow tooling.

## This diff
- Updates `Libraries/StyleSheet/processColorArray.js` to use `export` syntax.
- Appends `.default` to requires of the changed files.
- Updates test files.
- Updated View Config codegen (requires an MSDK bump).
- Updates the public API snapshot *(intented breaking change)*

Changelog:
[General][Breaking] - Files inside `Libraries/Text`, `Libraries/Share` and `Libraries/Settings` use `export` syntax, which requires the addition of `.default` when imported with the CJS `require` syntax.

Reviewed By: robhogan

Differential Revision: D68564304

fbshipit-source-id: 2fbd058be1a715cccfce4f2a68146118d8ac66ad
2025-01-28 09:46:50 -08:00
Riccardo Cipolleschi e77fe5c471 Bump React Native monorepo packages (#48975)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48975

After cutting 0.78-stable, we need to bump the monorepo packages to `0.79.0-main`

## Changelog:
[Internal] - Bump monorepo packages to `0.79.0-main`

Reviewed By: cortinico, huntie

Differential Revision: D68715005

fbshipit-source-id: cb5abbf05e8638683687be8d61d66b3037111572
2025-01-27 11:01:34 -08:00
Dawid Małecki f36bfe5dfa Remove redundant {||} syntax (#48686)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48686

Changelog:
[Internal] - Removed redundant `{||}` syntax

Reviewed By: javache

Differential Revision: D68205038

fbshipit-source-id: f7d3271142b6443a5859c3b668b7aebd3ce3ef3f
2025-01-15 07:07:01 -08:00
Rayner Kristanto 0f1d4704df Revert D68017325: Migrate StyleSheet/*.js to use export statements
Differential Revision:
D68017325

Original commit changeset: 3c5b94742f10

Original Phabricator Diff: D68017325

fbshipit-source-id: d7ea1edfe9cca151560e9c0e5554a07153cdb8da
2025-01-14 15:22:26 -08:00
Iwo Plaza e4d969a4ab Migrate StyleSheet/*.js to use export statements (#48609)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48609

# Motivation
This is an attempt at modernizing the export syntax in some of the files in `Libraries/StyleSheet/`. It will allow these files to get properly ingested by modern Flow tooling.

# This diff
- Migrates the use of `module.exports` into `export default` for files located in `Libraries/StyleSheet/*.js`. Some files were omitted due to ballooning complexity, but will be addressed in other Diffs.
- Updating internal *require*s to use ".default", no product code seems to be affected.
- Migrating `require`s into `import`s where applicable, taking into account the performance implications (context: https://fb.workplace.com/groups/react.technologies.discussions/permalink/3638114866420225/)
- Updates the current iteration of API snapshots (intended).
- Updates `react-native-codegen`'s require of processColorArray, analogous to D42346452.

Changelog:
[General][Breaking] - Deep imports from some files in `StyleSheet/` can break when using the `require()` syntax, but can be easily fixed by appending `.default`

Reviewed By: javache

Differential Revision: D68017325

fbshipit-source-id: 3c5b94742f101db0b2914c91efab6003dba2b61a
2025-01-14 05:34:18 -08:00
Eli White cf5ab03d43 Include cxx modules in codegen schema (#48581)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48581

Previously the CXX only modules were not being inclued in the schema for these apps, and therefore weren't being caught by the compat check.

Reviewed By: cipolleschi

Differential Revision: D68000360

fbshipit-source-id: 5d56bc840bd220f3b8b814e5d90eb49d9a2beb0b
2025-01-10 14:38:57 -08:00
David Vacca db57080e08 Refactor ViewManager codegen to use new ViewManagerInterface (#48549)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48549

Refactor ViewManager codegen to use new ViewManagerInterface

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D67957884

fbshipit-source-id: 7abcd453580ab2219770fd1aff780ba2977dfc8a
2025-01-10 13:58:28 -08:00
Nicola Corti 1282361573 Silence the eden info output from react-native-codegen (#48540)
Summary:
We currently see this error message on console:
![Screenshot 2025-01-08 at 19 09 47](https://github.com/user-attachments/assets/3b384772-9abc-40a5-83b3-9b4ccce85f4a)

This will silence it by piping stderr to /dev/null

## Changelog:

[INTERNAL] - Silence the `eden info` output from react-native-codegen

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

Test Plan: CI

Reviewed By: robhogan

Differential Revision: D67948411

Pulled By: cortinico

fbshipit-source-id: f805634a65713f4f9bc2dce6d781664e7564bc96
2025-01-09 04:01:29 -08:00
Eli White 25c673e357 Fixing schema types for component command params of Arrays (#48476)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48476

Command param array types were generating invalid schemas due to untyped parser code. The invalid schemas occurred for any alias type, including custom objects and basics like Int32. This was also inconsistent between Flow and TypeScript.

We already had one component utilizing this issue, so this just codifies that support into the schema so it reflects reality. This is only a partial solution. The more full solution would be to fully encode the custom types in the schemas like we do for Native Modules.

# More Information:

Tl;dr, DebuggingOverlay is abusing a FlowFixMe in codegen commands.

## The problem:

The [CodegenSchema](https://www.internalfb.com/code/fbsource/[d3ab2f79b377]/xplat/js/react-native-github/packages/react-native-codegen/src/CodegenSchema.js?lines=220) should be the source of truth for anything that can be in the schema. If something is in the schema that isn't allowed by the types, that's a bug. We have a bug. I'm adding compat-check support for components and it's blowing up on prod schemas because DebuggingOverlay causes an invalid schema.

## The details:

Support for Arrays as arguments in commands was added to the Codegen in D51866557. [Code Pointer](https://fburl.com/code/8yy1rm0p)

The intention appears to be to support arrays of primitives. There is a TODO for supporting complex types.

```
interface NativeCommands {
  +addOverlays: (
    viewRef: React.ElementRef<NativeType>,
    overlayColorsReadOnly: $ReadOnlyArray<string>,
  )
}
```

This support was added to TypeScript in D52046165 where it types the allowed Array arguments to be only

```
{
    readonly type: 'ArrayTypeAnnotation';
    readonly elementType:
    | Int32TypeAnnotation
    | DoubleTypeAnnotation
    | FloatTypeAnnotation
    | BooleanTypeAnnotation
    | StringTypeAnnotation
  };
```

However, because the Parsers are treating the input type as `any`, it isn't safe to pass through an input value into the schema as Flow won't catch mismatches.

The Flow parser just passes it through:

```
{
    type: 'ArrayTypeAnnotation',
    elementType: {
    // TODO: T172453752 support complex type annotation for array element
    type: paramValue.typeParameters.params[0].type,
}
```

Whereas the TypeScript parser has the more correct behavior of validating the inputs and returning specific outputs. Unfortunately, the return type is also typed here as $FlowFixMe, losing most of the benefits.

```
function getPrimitiveTypeAnnotation(type: string): $FlowFixMe {
  switch (type) {
    case 'Int32':
      return {
        type: 'Int32TypeAnnotation',
      };
    case 'Double':
      return {
        type: 'DoubleTypeAnnotation',
      };
    case 'Float':
      return {
        type: 'FloatTypeAnnotation',
      };
    case 'TSBooleanKeyword':
      return {
        type: 'BooleanTypeAnnotation',
      };
    case 'Stringish':
    case 'TSStringKeyword':
      return {
        type: 'StringTypeAnnotation',
      };
    default:
      throw new Error(`Unknown primitive type "${type}"`);
  }
}
```

[DebuggingOverlay](https://fburl.com/code/zfe3ipq7) is abusing this gap in the Flow parser by sticking an Array of Objects in.

```
export type ElementRectangle = {
  x: number,
  y: number,
  width: number,
  height: number,
};

...
  +highlightElements: (
    viewRef: React.ElementRef<DebuggingOverlayNativeComponentType>,
    elements: $ReadOnlyArray<ElementRectangle>,
  ) => void;
...
```

This isn't allowed in the schema, but it seems to fall through the holes of the flow parser and generators.

The resulting schema from Flow is this. Note the GenericTypeAnnotation which isn't allowed to be in the schema.

```
{
    "name": "highlightElements",
    "optional": false,
    "typeAnnotation": {
    "type": "FunctionTypeAnnotation",
    "params": [
        {
            "name": "elements",
            "optional": false,
            "typeAnnotation": {
                "type": "ArrayTypeAnnotation",
                "elementType": {
                    "type": "GenericTypeAnnotation"
                }
            }
        }
    ],
    "returnTypeAnnotation": {
        "type": "VoidTypeAnnotation"
    }
},
```

The TypeScript parser fails with `Error: Unsupported type annotation: GenericTypeAnnotation`.

The generators don't seem to check beyond the ArrayTypeAnnotation so they fall through to generating generic arrays.

```
// ios
elements:(const NSArray *)elements

// android
ReadableArray locations
```

## So how do I fix this?

I think there are a couple of different options here. The key problem is that the Schema types need to represent reality of what can be in the schema.

1. We revert DebuggingOverlay to not use features that aren't supported (I assume nobody would be happy with this, but the change shouldn't have been made in the first place)
2. **(This is the approach taken in this diff)** We add MixedTypeAnnotation to the allowed types in Command arrays and have it generate that and add official support for that to the TypeScript parser as well. That is probably the quickest and easiest approach. It leaves the same type unsafety we have today on the native side.
3. NativeModules seem to have a lot more complex type safety here. They persist the alias type in the schema so that the CompatCheck can check them on changes. And then in C++ they generate structs and RCTConvert functions although for Java and ObjC it looks like they just use the same untyped native code. The matching approach here would be to add `aliasMap` and the whole data to the schema for commands, use that for the compat check, and still generate the same unsafe native code.

```
export type ObjectAlias = {|
  x: number,
  y: number,
|};

export interface Spec extends TurboModule {
  +getAlias: (a: ObjectAlias) => string;
}
```

stores the ObjectAlias in the schema

```
{
  "aliasMap": {
    "ObjectAlias": {
      "type": "ObjectTypeAnnotation",
      "properties": [
        {
          "name": "x",
          "optional": false,
          "typeAnnotation": {
            "type": "NumberTypeAnnotation"
          }
        },
        {
          "name": "y",
          "optional": false,
          "typeAnnotation": {
            "type": "NumberTypeAnnotation"
          }
        },
      ]
    }
  },
  "spec": {
    "methods": [
      {
        "name": "getAlias",
        "optional": false,
        "typeAnnotation": {
          "type": "FunctionTypeAnnotation",
          "returnTypeAnnotation": {
            "type": "StringTypeAnnotation"
          },
          "params": [
            {
              "name": "a",
              "optional": false,
              "typeAnnotation": {
                "type": "TypeAliasTypeAnnotation",
                "name": "ObjectAlias"
              }
            }
          ]
        }
      }
    ]
  }
}
```

and then generates the appropriate structs on the native side and generates [this](https://www.internalfb.com/code/fbsource/[d3ab2f79b377]/xplat/js/react-native-github/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap?lines=818)

```

Reviewed By: hoxyq

Differential Revision: D67806838

fbshipit-source-id: 31f20455c816fdb6b1a86f8f9d0f6f7d0a452754
2025-01-06 18:42:37 -08:00
Eli White c748b44183 Add command type to CompleteTypeAnnotation (#48475)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48475

This will be needed for the compat-check.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D67806831

fbshipit-source-id: b660c9557cafbfa2e713e85a0fd2bdc9edabf537
2025-01-06 18:42:37 -08:00
Eli White 825492b199 Separate component array types and command array types (#48474)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48474

The previous definition said that you could put prop types into commands, which definitely isn't allowed.

For example, the schema would have allowed `WithDefault` types.

```
interface NativeCommands {
  +methodInt: (viewRef: React.ElementRef<NativeType>, a: WithDefault<string, 'hi'>) => void;
}
```

This change separates out the things that are allowed in commands from what's allowed in props.

Commands should be very similar to what's allowed in native modules, but it isn't exact enough to be able to merge those.

## Changelog:
[General][Breaking] - Codegen: Separate component array types and command array types

Reviewed By: cipolleschi

Differential Revision: D67806818

fbshipit-source-id: 58e504fe2e2e5efa612e836b18af22a167e7ae2f
2025-01-06 18:42:37 -08:00
Eli White c91cfd1ec1 Simplify CompleteTypeAnnotation (#48473)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48473

This is such a simpler approach lol.

I'll need this later for when I want to pass in arrays or objects of these types to the compat check

Changelog: [internal]

Reviewed By: cipolleschi

Differential Revision: D67806812

fbshipit-source-id: 5cc361815fea901098d2931ba78293693ecc0a35
2025-01-06 18:42:37 -08:00
Eli White 02c6790842 Make CompleteType contain module and component reserved names (#48477)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48477

Over the years of copying and moving and renaming types through CodegenSchema, this type ended up in the Command params, although the Command parser doesn't allow it.

I made this change to a fixture:

{F1974104959}

and got this error

```
 FAIL  xplat/js/react-native-github/packages/react-native-codegen/src/parsers/flow/components/__tests__/component-parser-test.js
  ● RN Codegen Flow Parser › can generate fixture COMMANDS_DEFINED_WITH_ALL_TYPES

    Unsupported param type for method "scrollTo", param "speed". Found UnionTypeAnnotation

      127 |       default:
      128 |         (type: empty);
    > 129 |         throw new Error(
          |               ^
      130 |           `Unsupported param type for method "${name}", param "${paramName}". Found ${type}`,
      131 |         );
      132 |     }
```

Also, a default value for enum an argument of a Command doesn't make sense anyways.

Commands should probably have support for enums and string literal unions, but that's out of scope here.

Still need to add to this vec\concat on www: https://www.internalfb.com/code/www/[ebfa58f888a6064e17879934d447f59bcc2b6951]/flib/intern/sandcastle/react_native/ota_steps/SandcastleOTACompatibilityCheckReportingStep.php?lines=62

Changelog: [internal]

Reviewed By: cipolleschi

Differential Revision: D67806808

fbshipit-source-id: f0f31cca30abbf61f569933ea7c49cf6bfd18a3f
2025-01-06 18:42:37 -08:00
Eli White 9e0a7e3263 Converge component's bespoke StringEnumTypeAnnotation into StringLiteralUnionTypeAnnotation (#48343)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48343

components store unions as 'StringEnumTypeAnnotation' even though it isn't actually a union, it's a literal.

Native Modules store these as 'StringLiteralTypeAnnotation' so this converges those and reuses the same types.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D67427656

fbshipit-source-id: e39028114285588584596012d07db40c117b4b94
2025-01-02 13:20:02 -08:00
Eli White b691122afc Share ArrayTypeAnnotation between components and modules (#48318)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48318

These structures were the same, but the component side didn't use generics and just had duplicates. Making a base one to be shared.

I need to follow up to this and constrain the types that components allow.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D67371894

fbshipit-source-id: bb1a30fcd0efe6cc567b88bc6f11e7b385bd7c41
2025-01-02 13:20:02 -08:00
Eli White 4dac99cf6d Fix FlowFixMes in CodegenVersionDiffing (#48312)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48312

I figured out how to fix these FlowFixMes

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D67313962

fbshipit-source-id: 21b109824411c1537f397aca45b7cdc2495f5e11
2024-12-17 20:23:24 -08:00
Eli White 949d229b5f Apply enum changes to new codegen version (#48000)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48000

Adding this type to CompleteTypes

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D65305755

fbshipit-source-id: 962297ba21b3b88f0117631fb4192c111e903fc6
2024-12-03 16:41:36 -08:00
Eli White fa8a25eb6b Make enum types annotation objects instead of literal strings and numbers (#47349)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47349

This is needed to be able to recurse into the literals and compare them.

I'm primarily unsure if there is a problem representing doubles/floats as numbers instead of strings though.

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D65284058

fbshipit-source-id: b2de9ed5fb7f079a432c94aaea69027863879909
2024-12-02 14:32:35 -08:00
Eli White 96c2be8567 Don't store pretty printed json in schema
Summary: Changelog: [Internal]

Reviewed By: javache

Differential Revision: D66603960

fbshipit-source-id: 2d7844df76f168b99eb76bb19359ee71e953d0b2
2024-12-02 14:32:35 -08:00
Sam Zhou d86412dcc6 prepare for primitive literal changes (#47943)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47943

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D66461724

fbshipit-source-id: b526ed1617667b70337472f4dad4e19f152a266b
2024-11-26 00:07:32 -08:00