From d4bf1b7af047e5fd8c100990f0df831985c02f46 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Fri, 27 Jun 2025 04:49:28 -0700 Subject: [PATCH] Remove experimental notice from V2 API snapshot and build by default (#52301) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52301 Readying for imminent productionisation. Changelog: [Internal] Reviewed By: j-piasecki Differential Revision: D77386064 fbshipit-source-id: 2769545eace4e6c09da0b2f0f34cf74b2fdcb730 --- .github/actions/build-npm-package/action.yml | 2 +- .github/actions/lint/action.yml | 2 +- .github/workflows/publish-bumped-packages.yml | 2 +- scripts/build-types/README.md | 12 ++++++------ scripts/build-types/index.js | 19 +++++-------------- .../templates/ReactNativeApi.d.ts-template.js | 2 -- 6 files changed, 14 insertions(+), 25 deletions(-) diff --git a/.github/actions/build-npm-package/action.yml b/.github/actions/build-npm-package/action.yml index ebc14ade32c..807e03a742c 100644 --- a/.github/actions/build-npm-package/action.yml +++ b/.github/actions/build-npm-package/action.yml @@ -129,7 +129,7 @@ runs: run: yarn build - name: Build types shell: bash - run: yarn build-types + run: yarn build-types --skip-snapshot # Continue with publish steps - name: Set npm credentials if: ${{ inputs.release-type == 'release' || diff --git a/.github/actions/lint/action.yml b/.github/actions/lint/action.yml index 9758f993668..236b07006dc 100644 --- a/.github/actions/lint/action.yml +++ b/.github/actions/lint/action.yml @@ -49,7 +49,7 @@ runs: run: yarn run lint-markdown - name: Build types shell: bash - run: yarn build-types + run: yarn build-types --skip-snapshot - name: Run typescript check of generated types shell: bash run: yarn test-generated-typescript diff --git a/.github/workflows/publish-bumped-packages.yml b/.github/workflows/publish-bumped-packages.yml index 1fd45999a64..f47ddd9fc03 100644 --- a/.github/workflows/publish-bumped-packages.yml +++ b/.github/workflows/publish-bumped-packages.yml @@ -21,7 +21,7 @@ jobs: - name: Build packages run: yarn build - name: Build types - run: yarn build-types + run: yarn build-types --skip-snapshot - name: Set NPM auth token run: echo "//registry.npmjs.org/:_authToken=$GHA_NPM_TOKEN" > ~/.npmrc - name: Find and publish all bumped packages diff --git a/scripts/build-types/README.md b/scripts/build-types/README.md index 7f8f484073b..861938098b1 100644 --- a/scripts/build-types/README.md +++ b/scripts/build-types/README.md @@ -11,7 +11,7 @@ Specifically, it reduces the runtime JavaScript API of `react-native` into two o - **Generated TypeScript types**\ Public user types for react-native, shipped to npm\ `packages/react-native/types_generated/` -- **‌Public API snapshot (experimental)**\ +- **‌Public API snapshot**\ Snapshot file of the public API shape, used by maintainers\ `packages/react-native/ReactNativeApi.d.ts` @@ -29,11 +29,11 @@ Snapshot file of the public API shape, used by maintainers\ > API snapshot generation is currently **experimental**, and will be folded into the default behaviour when ready. ```sh -# Build types -yarn build-types +# Build types + API snapshot +yarn build-types [--validate] -# Build types + API snapshot (experimental) -yarn build-types --withSnapshot [--validate] +# Build types without API snapshot +yarn build-types --skip-snapshot ``` #### Configuration @@ -54,7 +54,7 @@ Directory providing TypeScript user types for the `react-native` package, distri - Preserves doc comments. - Preserves source file names (for go to definition). -### Public API snapshot (experimental) +### Public API snapshot `ReactNative.d.ts` diff --git a/scripts/build-types/index.js b/scripts/build-types/index.js index 989a9b17f8a..77b672d2655 100644 --- a/scripts/build-types/index.js +++ b/scripts/build-types/index.js @@ -20,7 +20,7 @@ const config = { debug: {type: 'boolean'}, 'debug-version-annotations': {type: 'boolean'}, help: {type: 'boolean'}, - withSnapshot: {type: 'boolean'}, + 'skip-snapshot': {type: 'boolean'}, validate: {type: 'boolean'}, }, }; @@ -31,7 +31,7 @@ async function main() { debug: debugEnabled, 'debug-version-annotations': debugVersionAnnotations, help, - withSnapshot, + 'skip-snapshot': skipSnapshot, validate, }, /* $FlowFixMe[incompatible-call] Natural Inference rollout. See @@ -49,7 +49,7 @@ async function main() { --debug-version-annotations Outputs debug info alongside versioned type hashes as part of the API snapshot contents. - --withSnapshot [Experimental] Include API snapshot generation. + --skip-snapshot Skip API snapshot generation. --validate Validate if the current API snapshot on disk is up to date. Exits with an error if differences are detected. `); @@ -57,14 +57,6 @@ async function main() { return; } - if (validate && !withSnapshot) { - console.error( - "build-types: '--validate' can only be used with '--withSnapshot'.", - ); - process.exitCode = 2; - return; - } - if (debugEnabled) { debug.enable('build-types:*'); } @@ -79,10 +71,9 @@ async function main() { ); await buildGeneratedTypes(); - if (withSnapshot) { + if (!skipSnapshot) { console.log( - styleText(['bold', 'inverse'], ' [Experimental] Building API snapshot ') + - '\n', + styleText(['bold', 'inverse'], ' Building API snapshot ') + '\n', ); await buildApiSnapshot({validate, debugVersionAnnotations}); } diff --git a/scripts/build-types/templates/ReactNativeApi.d.ts-template.js b/scripts/build-types/templates/ReactNativeApi.d.ts-template.js index 52c76567e12..c848b909bff 100644 --- a/scripts/build-types/templates/ReactNativeApi.d.ts-template.js +++ b/scripts/build-types/templates/ReactNativeApi.d.ts-template.js @@ -19,8 +19,6 @@ function apiSnapshotTemplate(source: string): string { * LICENSE file in the root directory of this source tree. * * ${signedsource.getSigningToken()} - * @${'nocommit'} EXPERIMENTAL V2 API SNAPSHOT - Continue to use public-api-test.js - * until we productionize this format. * * This file was generated by scripts/build-types/index.js. */