81 Commits
Author SHA1 Message Date
Sam Zhou fdcce4f673 Turn on experimental.new_this_typing in xplat (#58293)
Summary:
Pull Request resolved: https://github.com/react/react-native/pull/58293

Changelog: [Internal]

Reviewed By: vzaidman

Differential Revision: D118513884

fbshipit-source-id: a33a81eab930ac29663410cf04163aebb87062ad
2026-09-02 13:03:29 -07:00
generatedunixname1026736676487289 2fa055f6a7 Upgrade Flow in fbsource (#58192)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/58192

Reviewed By: SamChou19815

Differential Revision: D117992492

fbshipit-source-id: bc3a32b4420243b6675439e0840559b85507c3dd
2026-08-29 11:23:04 -07:00
Alex Hunt 89300acb9c Migrate Node.js builtin imports to node: scheme (#57611)
Summary:
Pull Request resolved: https://github.com/react/react-native/pull/57611

Directly follows D112733139 (Metro).

**Motivation**

- New Node builtins are *only* available under the prefix (e.g. `node:sqlite`), as this allows Node to introduce them without ecosystem-breaking changes, so this is the direction of travel and the only choice that'll allow consistency.
- Encouraging them and grouping them separately makes it easier to reason about a module's 3rd party dependencies.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D112803684

fbshipit-source-id: 40668d746a7151b3aa4800ff8af997902a18d198
2026-07-21 09:01:41 -07:00
Rubén Norte 0fae86d0c7 Remove deprecated FANTOM_ENABLE_CPP_DEBUGGING environment variable (#57401)
Summary:
Pull Request resolved: https://github.com/react/react-native/pull/57401

The `FANTOM_ENABLE_CPP_DEBUGGING` environment variable was kept only as a legacy alias for `FANTOM_DEBUG_CPP`. Remove it from Fantom so `FANTOM_DEBUG_CPP` is the single supported way to enable the C++ debugger.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D110324557

fbshipit-source-id: 2cbde4736137db792b8b99d1806c146e3094ca4b
2026-07-01 08:18:34 -07:00
Rubén Norte 2bb7dbb499 Add an interactive REPL for Fantom (yarn fantom-cli) (#57387)
Summary:
Pull Request resolved: https://github.com/react/react-native/pull/57387

Adds `yarn fantom-cli`, an interactive REPL that evaluates JavaScript against the same native tester binary and Hermes runtime that Fantom tests run in. State persists across lines, input goes through Metro/Babel (so `import`, JSX and Flow all work), and the environment is set up the same way tests set it up — `React`, `ReactNative` and the `Fantom` API are available globally, so you can render surfaces and drive them interactively from the prompt.

The native tester gains an `--interactive` mode that loads a warm-up bundle without running tests and then evaluates length-prefixed snippets read from stdin, reporting results, console output and errors back as newline-delimited JSON. A Node driver hosts a Metro server, builds the warm-up bundle, spawns the binary, and bridges each line of input into the live runtime (top-level declarations persist across evaluations).

Features:

- Console-style output: results are printed with an inspector similar to the Chrome DevTools / Node.js consoles (nested objects/arrays up to a depth limit, quoted strings, functions/classes, `Map`/`Set`/`RegExp`/`Date`/`Error`, class instances, circular references, multi-line wrapping), colorized by type when stdout is a terminal. Inspecting a property never aborts the result or leaks into later evaluations: a property whose getter fails renders as `[Thrown: <error>]`, including getters that fail asynchronously through the runtime's global error handler (e.g. accessing a `react-native` export backed by a TurboModule that isn't registered).
- Autocompletion: pressing Tab completes global identifiers, in-scope bindings and object properties (property names are listed without invoking getters).
- Node-like CLI: with no arguments it starts the REPL; `-e <code>` evaluates a snippet and exits; a filename runs that script and exits. In the non-interactive modes the value of a trailing expression is not printed (use `console.log`) and a thrown error exits with a non-zero status code.

Also documents the REPL in the Fantom README.

Changelog: [Internal]

Reviewed By: javache, sammy-SC

Differential Revision: D110187712

fbshipit-source-id: 3e76c498ae04b8b1ce9e0e27e5ce6b6a0cd11e09
2026-07-01 08:18:34 -07:00
Rob Hogan 014fe8b520 Refactor imports from Metro to avoid deprecated styles and prefer main package (#57378)
Summary:
Pull Request resolved: https://github.com/react/react-native/pull/57378

Refactor Metro imports to:
 - Remove use of deprecated default object export, prefer named/namespace exports.
 - Prefer imports from `metro`, remove public dependencies on `metro-core` and `metro-config` from `react-native/community-cli-plugin`.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D110177050

fbshipit-source-id: f21a561d40d13f354bc56cdc50d6e6d6843877cc
2026-06-30 09:42:04 -07:00
Rubén Norte e1b0c77507 Fix Fantom dev-mode tests when the tester is built in optimized mode (#57272)
Summary:
Pull Request resolved: https://github.com/react/react-native/pull/57272

Fantom integration tests declared with `fantom_mode dev` rely on debug-only native APIs (e.g. timer mocking via `installHighResTimeStampMock`) that are only compiled when the native tester is built in debug mode.

Under some build configurations the active platform pins the core build mode to optimized, so the preprocessor flag that gates those debug-only APIs is not defined and the tester is compiled in optimized mode. As a result, dev-mode tests that depend on those APIs throw at runtime (e.g. "Mocking timers is not supported in optimized builds").

A previous attempt stacked a build-mode constraint on the Hermes build mode setting, which the native preprocessor flags never read, so it had no effect. Stack the constraint on the core build mode setting that actually gates the flag instead, so the tester is compiled in the test's intended dev/opt mode.

Changelog: [Internal]

Reviewed By: ellemac123

Differential Revision: D109014401

fbshipit-source-id: a04d75d299e3d2a0d1ccabcc2629833ac7a9dbd6
2026-06-18 07:20:47 -07:00
Rubén Norte 9199b3933a Add Fantom.getHostPlatform() to expose test runner host OS (#56990)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56990

Adds a new `Fantom.getHostPlatform()` API that returns the host
operating system where the Fantom test runner is running (e.g. 'linux',
'macos', 'windows', 'android'). This is different from React Native's
`Platform.OS`, which always reflects the React Native target platform
being tested.

The value is determined by the Node.js Jest runner (via
`process.platform`) and baked into the JS bundle through the existing
`setConstants(...)` pipeline, so no native changes are needed.

- Add `HostPlatform` type and `hostPlatform` field to
  `FantomRuntimeConstants`.
- Populate `hostPlatform` from the host platform in the entrypoint
  template (maps darwin -> macos, win32 -> windows, etc.).
- Expose `getHostPlatform()` from the public Fantom API.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D106669673

fbshipit-source-id: 6948e0c1eb0075131211d8c5099da96a87306b0a
2026-05-29 08:02:57 -07:00
Rubén Norte 5c55a61c1f Set hermes_build_mode constraint when building tester with coverage (#56541)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56541

The Fantom test runner spawns native `fantom-tester` binaries built in
either dev or opt mode based on each test's `fantom_mode` pragma. When
collecting C++ code coverage of the tester binary, however, the build
may switch to a coverage-instrumented build configuration that does not
define `REACT_NATIVE_DEBUG`.

That breaks dev-mode tests that rely on debug-only native APIs. For
example, `installHighResTimeStampMock` in
`private/react-native-fantom/tester/src/NativeFantom.cpp` is gated on
`#ifdef REACT_NATIVE_DEBUG` and throws "Mocking timers is not supported
in optimized builds" otherwise. Tests like `LongTasksAPI-itest.js` (no
`fantom_mode` pragma → defaults to dev) fail in CI coverage runs with
that error.

When invoking buck with coverage enabled, layer the `hermes_build_mode`
constraint on top of the build platform so `rn_build_mode()` (in
`tools/build_defs/oss/rn_defs.bzl`) picks up the right value and adds
`-DREACT_NATIVE_DEBUG` for dev tests.

Reviewed By: fkgozali

Differential Revision: D101832028

fbshipit-source-id: cfb5269dea846f41d9d1f9af1c5ff8bd5828085c
2026-04-21 11:15:04 -07:00
Rubén Norte dbd3255194 Build both coverage and non-coverage tester binaries in CI (#56538)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56538

The Fantom Jest `globalSetup` builds the `fantom-tester` native binaries
upfront, using `globalConfig.collectCoverage` to decide whether to build
the `-coverage` flavor.

However, `runner/coverageUtils.js`'s `shouldCollectCoverage()` returns
`false` for some tests even when `globalConfig.collectCoverage` is true:

- All benchmarks (filename matches `*Benchmark-itest.*`)
- Tests with the `fantom_disable_coverage` pragma

In CI coverage runs, those tests resolve their tester binary path with
`enableCoverage=false` (e.g. `fantom-tester-statichermesstable-opt`),
but `globalSetup` only built the `-coverage` variants, so spawn fails
with `ENOENT` and the test fails with an empty stdout/stderr and exit
code `-2`.

When `enableCoverage` is true, also build the non-coverage tester
variants so coverage-opt-out tests can find their binary.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D101819861

fbshipit-source-id: e82f7c8c548c9477d214e9265c813bf9b54ab141
2026-04-21 09:24:25 -07:00
Rubén Norte c1ffe9f2a0 Harden Metro bundle retry against file-watcher races (#56530)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56530

Each Fantom test writes a unique `\-<test>.js` entrypoint into
`.out/js-builds/` and then asks Metro to bundle it. Metro's file watcher
(metro-file-map's `FallbackWatcher` on Linux, debounced 100 ms) does not
always observe the new entrypoint by the time the HTTP request arrives,
especially when multiple workers are writing entrypoints concurrently.
The previous retry logic was too narrow:

- Only HTTP 404 was treated as retryable. Metro returns 404 only when the
  entry file path itself can't be resolved; an unresolved transitive
  dep (e.g. `setUpDefaultReactNativeEnvironment`) returns HTTP 500 with
  `{type: 'UnableToResolveError'}` — we'd throw immediately on that.
- Only 3 attempts with a flat 500 ms wait (~1 s total), which is not
  enough on a busy host with 8 workers writing entrypoints at once.

This results in ~30 spurious "Failed to request bundle from Metro: Unable
to resolve module ..." failures per run.

Refactor `createBundle` into a focused `fetchBundleWithRetry` helper that:

- Parses Metro's JSON error envelope (`{type, message, ...}` from
  `formatBundlingError`) once per response and uses `type` to decide
  whether to retry. Retries on HTTP 404, on HTTP 500 with
  `UnableToResolveError` or `ResourceNotFoundError`, and on transient
  `fetch` network errors. All other failures (transform errors, syntax
  errors, real config issues) throw immediately so we don't waste seconds
  on them.
- Uses exponential backoff (100 ms → 200 → 400 → 800 → 1.6 s, capped at
  2 s) with up to 10 attempts (~11 s total worst case).
- Surfaces a clean error message (parsed from the JSON envelope) when
  retries are exhausted.

Changelog: [Internal]

Reviewed By: andrewdacenko

Differential Revision: D101791796

fbshipit-source-id: 805ef9bc6e58fce7c1dc10d0cbbb7fdfa1fa24a5
2026-04-21 06:03:40 -07:00
Pieter De Baets 3fb1fea57e Evict Metro bundle graphs after each Fantom test to prevent OOM (#56514)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56514

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D101652820

fbshipit-source-id: f7608fbf92a8fd2928434e74ad03bfc01b318d20
2026-04-20 10:56:52 -07:00
Rubén Norte def621f674 Move CI validation for debugCpp and profileCpp to EnvironmentOptions (#56464)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56464

Changelog: [internal]

Moved the CI validation checks for `debugCpp` and `profileCpp` from the `run()` function in `tester.js` to `validateEnvironmentVariables()` in `EnvironmentOptions.js`, alongside the existing CI/OSS validation for memory instrumentation.

This centralizes all environment option validation in one place, so invalid configurations are caught early during environment setup rather than at tester execution time.

Reviewed By: javache

Differential Revision: D101159820

fbshipit-source-id: 1e488db6e9de3eb3bac840c4931bb1536f8b5efb
2026-04-16 06:23:35 -07:00
Rubén Norte 7efb4b564e Run benchmarks in test mode by default instead of excluding them (#56418)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56418

Changelog: [internal]

D92150163 excluded benchmark tests by default when running `yarn fantom` without `--benchmarks`. This was incorrect because it means benchmarks could silently break without being caught.

This changes the behavior so:
1. By default (without `--benchmarks`), benchmarks run in test mode (single iteration for correctness only), ensuring they do not break.
2. With `--benchmarks`, benchmarks run in full benchmark mode (multiple iterations for performance measurement).

Also renames `FANTOM_FORCE_TEST_MODE` to `FANTOM_RUN_BENCHMARKS` and `forceTestModeForBenchmarks` to `runBenchmarks` to better reflect the intent (opt-in to full benchmarks rather than opt-in to test mode).

Reviewed By: sammy-SC

Differential Revision: D100464314

fbshipit-source-id: 822cc5a25f0cdddf035616fdddf8619d27ef436a
2026-04-13 04:31:04 -07:00
Rubén Norte 4bdfaf222b Fix stateful regex bug in benchmark detection (#56423)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56423

Changelog: [Internal]

The `FANTOM_BENCHMARK_FILENAME_RE` and `FANTOM_BENCHMARK_SUITE_RE` regexes used the `g` (global) flag, which makes `.test()` stateful — it preserves `lastIndex` between calls. When `getFantomTestConfigs` is called for multiple test files in the same process, the stale `lastIndex` from a previous successful match causes `.test()` to miss the match on the next file, returning `false`. This results in benchmark files intermittently getting the default dev config (`isJsOptimized: false`, `dev: true`), causing them to fail at runtime with "Benchmarks should not be run in development mode".

Removes the `g` flag from both regexes since they are used with `.test()` across different strings and should be stateless.

___

overriding_review_checks_triggers_an_audit_and_retroactive_review
Oncall Short Name: react_native_iroc

Differential Revision: D100603612

fbshipit-source-id: 4eded9b0a59a2343ad44c0c1c2855466e3981b7a
2026-04-13 04:31:04 -07:00
Sam Zhou 82bffce573 Cleanup legacy flow types in react-native (#56300)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56300

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D99004126

fbshipit-source-id: dfedc13c867cb768777e2ba65256a2c40ffb1d08
2026-03-31 19:25:25 -07:00
Marco Wang 53cd9cec15 transformTypeParamBound codemod 9/9 (#55948)
Summary:
X-link: https://github.com/facebook/metro/pull/1665

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

js1 flow-runner codemod flow/transformTypeParamBound --format-files=false xplat/js

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D95429551

fbshipit-source-id: 6f5694fed74364c6f1c58e28376c86eae6201366
2026-03-05 21:26:42 -08:00
Andrew Datsenko 43278f94d2 Add toMatchInlineSnapshot support (#55892)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55892

Adds `toMatchInlineSnapshot()` to the Fantom custom `expect` implementation,
matching Jest's inline snapshot behavior. On first run, snapshot values are
written directly into the test source file as template literal arguments.
On subsequent runs, values are compared and the test fails on mismatch
unless the `-u` flag is passed to force an update.

The implementation spans the two-process Fantom architecture:

**Runtime (Hermes VM):**
- `snapshotContext.js`: New `toMatchInlineSnapshot` method that compares
  received values against existing inline snapshots, captures stack traces
  for new/mismatched snapshots, and tracks results per test.
- `expect.js`: New `toMatchInlineSnapshot` method on the `Expect` class
  that serializes values with `prettyFormat` and delegates to snapshot context.
- `setup.js`: Plumbs `inlineSnapshotResults` through `TestCaseResult`.

**Runner (Node.js):**
- `snapshotUtils.js`: New `processInlineSnapshotResults` resolves VM stack
  traces back to original source locations via source map symbolication.
  New `saveInlineSnapshotsToSource` directly rewrites the test source file
  by finding each `toMatchInlineSnapshot(...)` call and replacing its
  argument with the formatted template literal. This avoids jest-snapshot's
  `saveInlineSnapshots` which requires Babel and Prettier 2.x.
- `runner.js`: Generates source maps when inline snapshots need updating,
  collects pending snapshots across test configs, and writes them after
  all configs complete.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D95077617

fbshipit-source-id: 6a25c8ce966ed71ecd8977c13c25de5907311c6e
2026-03-05 11:14:41 -08:00
Andrew Datsenko e1c296869d add cpp coverage (#54637)
Summary:
Changelog: [Internal]

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

Add c++ code-coverage mode for Fantom and set up custom output path for it.

Reviewed By: sammy-SC

Differential Revision: D87548065

fbshipit-source-id: 5462582ca467051f7e9a155fd82bfb7045380097
2026-03-03 09:28:25 -08:00
Andrew Datsenko c4a982920d Add LLVM coverage conversion to LCOV format (#55860)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55860

Changelog: [Internal]

This diff adds the ability to convert LLVM coverage JSON output to LCOV format for C++ code coverage in react-native-fantom.

Key additions:
- `convertLLVMCoverage.js`: Converts LLVM coverage data (segments, branches, functions) to LCOV format lines
- `types.flow.js`: Flow type definitions for LLVM coverage data structures
- Test utilities and fixtures for validating the conversion with real coverage data from various C++ files (AppSettings.cpp, Class.h, DevSettingsModule.h, NativeFantom.cpp/h, RawPropsKey.cpp)

This enables reporting C++ code coverage from Fantom tests in a standard format that can be consumed by coverage tools.

Reviewed By: sammy-SC

Differential Revision: D90135000

fbshipit-source-id: 3b22250c4b1665748b6ccb4feb79cc1c20ec7fa6
2026-03-03 09:28:25 -08:00
Nick Lefever b2efda00a8 Improve bundling error message formatting (#55794)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55794

Format the error messages coming from bundling to mainting the formatting and make these easier to read.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D94611951

fbshipit-source-id: cbb8b2d1ff517b5487d4b799b1e2e3476629f84c
2026-03-01 17:49:19 -08:00
Samuel Susla 1eca581446 Add C++ sampling profiler support with FANTOM_PROFILE_CPP (#55735)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55735

changelog: [internal]

Add support for profiling C++ code in Fantom tests using Linux `perf`.

When `FANTOM_PROFILE_CPP=1` is set, the fantom_tester binary is wrapped with `perf record` to capture sampling profiler data with DWARF call graphs.

Usage:
```
FANTOM_PROFILE_CPP=1 yarn fantom --benchmarks --testPathPattern="View-benchmark"
```

Output is saved to `.out/cpp-traces/perf-<timestamp>.data` and can be analyzed with:
```
perf report -i .out/cpp-traces/perf-<timestamp>.data
```

Reviewed By: rubennorte

Differential Revision: D92155573

fbshipit-source-id: bde3ffcd11468e4ad88bec4b547726bed7cbde41
2026-02-27 04:03:13 -08:00
Alex Hunt 703fe8b222 Add module mock for DefaultToolLauncher and apply in tests (#55728)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55728

Fixes unwanted side effect launches of the debugger shell in tests (likely introduced in D88161573!).

Also adds error guard on `DefaultAppLauncher` to ensure that the implementation is always mocked.

Changelog: [Internal]

Reviewed By: vzaidman

Differential Revision: D94230761

fbshipit-source-id: 966f6f09c38aa55594091bd7d34a5c78dc6eee93
2026-02-26 12:12:16 -08:00
Nick Lefever 017bf1a7f0 Fix asan/tsan env options handling (#55753)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55753

The warning "ASAN and TSAN modes cannot be used together" was incorrectly displayed when only ASAN was enabled. This happened because the condition checked only `enableASAN` instead of `enableASAN && enableTSAN`. Updated the conditional logic to properly check that both flags are enabled before showing the conflict warning.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D94393117

fbshipit-source-id: f7a96de11230710e8d54c17d4c89edb569ebaa07
2026-02-25 13:19:50 -08:00
Samuel Susla 89df2e3a75 Fix Buck2 --out permission errors on macOS for claude code (#55736)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55736

changelog: [internal]

On macOS with EdenFS backed directories, Buck2's --out flag fails with "Operation not permitted" error.

This fix works around the issue by:
1. Building to a temp directory outside the repo (os.tmpdir())
2. Removing extended attributes with `xattr -rc` on macOS

Reviewed By: cipolleschi

Differential Revision: D92078500

fbshipit-source-id: 437734c068e4bf20a4f8e570e1184565810154d3
2026-02-25 05:16:09 -08:00
Samuel Susla 677330a6d6 Exclude benchmark tests by default, add --benchmarks flag (#55725)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55725

changelog: [internal]

By default, `yarn fantom` now excludes benchmark tests (`*-benchmark-itest.js` files) to speed up regular test runs.

Benchmark tests are typically slower and used for performance analysis rather than correctness testing. Excluding them by default improves the developer experience for everyday test runs.

To run benchmark tests, use the new `--benchmarks` flag:
```
yarn fantom --benchmarks
```

Reviewed By: andrewdacenko

Differential Revision: D92150163

fbshipit-source-id: 4c40ef1ba542c4856221373d8239ba603e8f6620
2026-02-25 03:17:00 -08:00
Samuel Susla 1707d30025 stop standalone Devtools from starting in Fantom (#55713)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55713

changelog: [internal]

when running Fantom on Mac, I frequently see this error. This is DevTools standalone app crashing. Let's disable DevTools standalone app, it is not needed with tests anyway.

 {F1985865132}

Reviewed By: huntie

Differential Revision: D94092247

fbshipit-source-id: 440e4482102b2f4152eb63c04023b01867250213
2026-02-24 09:39:47 -08:00
Zeya Peng 4cfb2ee468 enable -DRN_USE_ANIMATION_BACKEND by default (#55266)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55266

## Changelog:

[General] [Changed] - enable -DRN_USE_ANIMATION_BACKEND by default

Reviewed By: cipolleschi

Differential Revision: D91056420

fbshipit-source-id: bd8ef6b63a593540688c1af6a25274d047f43f9b
2026-01-23 07:49:20 -08:00
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
Pieter De Baets bc8970ec9e Fix Hermes opt mode for local mac runs (#55138)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55138

Some tests were failing locally on Mac, since //arvr/mode/mac-arm/opt doesn't correctly undefine REACT_NATIVE_DEBUG. Use `//xplat/mode/hermes/opt` as a short-cut since that directly defines rn_build_mode.

Changelog: [Internal]

Reviewed By: zeyap

Differential Revision: D90536112

fbshipit-source-id: 55aeb78970c9d210206a6d86cd3e57d55b0a6396
2026-01-13 06:40:10 -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
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 f41f3bf41f Transform all Flow legacy utility types ($NonMaybeType) to TypeScript-style types in xplat/js (#54935)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54935

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: gkz

Differential Revision: D89494075

fbshipit-source-id: 1bc3e0039dfb5bf04f1860d5098e024fb8491647
2025-12-19 01:35:12 -08:00
Gang Zhao 11f6ffd139 Add DEFAULT_OSS_HERMES_VARIANT and change DEFAULT_HERMES_VARIANT to use SH internally (#54543)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54543

Changelog: [Internal]

We are switching to SH as default, so internally, we need to switch
DEFAULT_HERMES_VARIANT to use SH stable. To keep the tests working in
OSS, we add DEFAULT_OSS_HERMES_VARIANT to use legacy Hermes.

Reviewed By: cipolleschi

Differential Revision: D87082037

fbshipit-source-id: f2fa00d6922816881201d736aeb6591745127d4c
2025-11-17 11:52:11 -08:00
Rubén Norte 9c4601abec Clean up feature flag "enableAccessToHostTreeInFabric" (#54322)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54322

Changelog: [internal]

This just cleans up the feature flag, which is set to `true` by default and it's been enabled in `stable` already.

Reviewed By: lunaleaps, yungsters

Differential Revision: D85782127

fbshipit-source-id: 0a6174708066cfe597b4c6dbc8bb33829c6155e9
2025-10-30 08:37:04 -07:00
Zeya Peng d2eca58996 use processor flag -DRN_USE_ANIMATION_BACKEND to gate animation backend dep (#54091)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54091

## Changelog:

[Internal] [Changed] - use processor flag -DRN_USE_ANIMATION_BACKEND to gate animation backend dep

So it's only enabled for catalyst and fantom when building with BUCK while gated from other meta apps, and enabled by default in oss version

Reviewed By: sammy-SC

Differential Revision: D84157729

fbshipit-source-id: e822f11c4b64b77b17a698bf3b60b5c5a4faf4f4
2025-10-09 19:01:20 -07:00
Vitali Zaidman 3a954caf4f don't require projectRoot in devMiddleware (#53921)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53921

Changelog: [Internal] `devMiddleware` removed the unused option `projectRoot`

This option was used only in a dead branch of the code inside `InspectorProxy`.

The scenario where it appeared was enabling resolving script sources (`Debugger.getScriptSource`) starting with `file://` which were coming from the file system. However, we don't seem to ever point scripts at the filesystem this way.

Reviewed By: huntie

Differential Revision: D82739662

fbshipit-source-id: 9a130eaa83cb94ae0e36a5a1102c56ff8a36cffc
2025-09-24 12:47:24 -07:00
Andrew Datsenko 22002bb70c Allow to disable coverage via flag & disable it for benchmarks (#53912)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53912

Changelog: [Internal]
Add new fantom flag `fantom_disable_coverage` to be used in tests that are sensitive to things like memory allocation.
Also disable coverage for any benchmark test.

Reviewed By: arushikesarwani94

Differential Revision: D83070065

fbshipit-source-id: a885e79e3d0c88cfb7adef30cb60ab46a617edac
2025-09-23 13:40:31 -07:00
Andrew Datsenko e97ef8f1fb Fix dotslash issue in OD (#53842)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53842

Changelog: [Internal]
There is a conflict between dotslash in node_modules and in OD it does not invoke buck2

Reviewed By: javache

Differential Revision: D82724326

fbshipit-source-id: c90cab58818e0245f8763b729c7e5432735eb05e
2025-09-18 07:39:22 -07:00
Andrew Datsenko 10a46f7b52 Add support for JS coverage (#53410)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53410

Changelog: [Internal]
Adding babel-istanbul-plugin to instrument bundle code with coverage reporting.
Metro will transform source code only when coverage flag is set up globally in jest.
Coverage map is then provided by runner as part of test result.

Reviewed By: sammy-SC

Differential Revision: D80716433

fbshipit-source-id: 3831f227f8793f874f0d2366759bb6916e747c72
2025-09-04 07:19:56 -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
Ruslan Shestopalyuk e3183739bb Options to run Fantom with address and thread sanitizers enabled (#53300)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53300

# Changelog:
[Internal] -

This adds two new modes to Fantom, allowing to run the native (C++) side with enabling either:
* Address sanitizer, which would detect memory overwrites
* Thread sanitizer, which can detect potential threading issues, such  as race conditions

This are opt-in for now.

Currently, both modes already detect different errors, which have a high chance to be real issues and have to be fixed.

Reviewed By: lenaic

Differential Revision: D80339524

fbshipit-source-id: 784ddb9f0af79a04b074e107e4955724d54d5685
2025-08-15 08:12:04 -07:00
Ruslan Shestopalyuk 641a79dc51 Improve benchmark comparison printout ("slower"->"faster") (#53221)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53221

# Changelog:
[Internal] -

This changes the benchmark test results comparison print the results slightly differently, in particular it now uses the slowest result as a baseline and prints how much faster the other ones are (as opposed to printing "slower" previously).

This arguably brings a more positive vibe when looking into the benchmark results :)

Reviewed By: andrewdacenko

Differential Revision: D80082134

fbshipit-source-id: 7dc9c7c520afe08270d4f5da9031db02261690ba
2025-08-12 06:56:14 -07:00
Rubén Norte 65974e938c Add support for JS debugging in Fantom (#53215)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53215

Changelog: [internal]

This adds a new environment variable to Fantom that allows debugging the JS code in tests.

Usage:

```
FANTOM_DEBUG_JS=1 yarn fantom <test>
```

**Does NOT work in OSS yet**. We need to include a third-party library to send HTTP and WebSocket requests and implement a wrapper on top of it.

Reviewed By: christophpurrer

Differential Revision: D79883372

fbshipit-source-id: d077c373a036033344e61d58274d5cd14028bda4
2025-08-12 05:41:11 -07:00
Rubén Norte e0b22e1ebf Rename global variable with Metro server for Fantom (#53202)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53202

Changelog: [internal]

Just a minor refactor to follow the convention of prefixing Fantom-related globals and environment variables.

Reviewed By: rshest

Differential Revision: D79804007

fbshipit-source-id: 0c9a57c1b08ae18ae03cd66d1a6ef9690e0dea42
2025-08-12 05:41:11 -07:00
Rubén Norte 6fb0072f01 Refactor logic to find available port for Metro in Fantom (#53204)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53204

Changelog: [internal]

This changes the logic to find an available port for Metro on Fantom to do this outside Metro. Before, we'd set `0` as the port for Metro to find an available port, but in a following change we'll need to know the port before calling into Metro. This allows that.

Reviewed By: rshest

Differential Revision: D79804005

fbshipit-source-id: 5c2e2f4acbba3a79771586799b65653d46b8fe72
2025-08-12 05:41:11 -07:00
Rubén Norte 2f33eece41 Fix retry logic in Fantom when requesting bundles from Metro (#53161)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53161

Changelog: [internal]

This fixes a bug in the retry logic in Fantom when requesting bundles from Metro, where we cache the error from a previous attempt and use it to determine we didn't succeed after the attemps.

Reviewed By: rshest

Differential Revision: D79881488

fbshipit-source-id: 566b2d700db2f9653b9ea9acd577d7eb03770b76
2025-08-08 04:22:16 -07:00
Ruslan Shestopalyuk 5fc23d7c62 Add type-safe API for passing around benchmark results (#53143)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53143

# Changelog:
[Internal] -

This refactors the way Fantom benchmark test results are passed to the top level, making it type safe and more maintainable.

Reviewed By: andrewdacenko

Differential Revision: D79812707

fbshipit-source-id: d8bfef7e1b0c11b277a08f5e4c810f8c1efd7f89
2025-08-07 10:46:26 -07:00
Ruslan Shestopalyuk 77ee24ddce Print benchmark comparison results in a tabular format (#53097)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53097

# Changelog:
[Internal] -

This makes the benchmark results comparison printout, added in https://github.com/facebook/react-native/pull/52925, be done in a tabular form, so it's easier to read and copy/paste around.

Reviewed By: lenaic

Differential Revision: D79728695

fbshipit-source-id: 4dfc999ad4a9a8c2d67efdfce11aff75383cf645
2025-08-07 08:11:32 -07:00