From f6ba2dbf3b4c85da1a7f9079fd366a41b160fa69 Mon Sep 17 00:00:00 2001 From: riteshshukla04 Date: Thu, 14 Aug 2025 09:02:43 -0700 Subject: [PATCH] Add types for platform in React native web (#53216) Summary: This PR fixes https://github.com/facebook/react-native/issues/52356. As per discussion here https://github.com/facebook/react-native/pull/52360 . We have changed the implementation in React native web in this PR https://github.com/necolas/react-native-web/pull/2791. As discussed with cortinico , Now web returns a hardcoded string "0.0.0" for `platform.version`. We can safely change this to string now. ## Changelog: [GENERAL][CHANGED] Update types for Platform.version Pull Request resolved: https://github.com/facebook/react-native/pull/53216 Test Plan: N/A Reviewed By: christophpurrer Differential Revision: D80173301 Pulled By: necolas fbshipit-source-id: 750aae2427a6c36a068346a9722d9734d9906b58 --- packages/react-native/Libraries/Utilities/Platform.d.ts | 1 + packages/react-native/Libraries/Utilities/PlatformTypes.js | 2 +- packages/react-native/ReactNativeApi.d.ts | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/react-native/Libraries/Utilities/Platform.d.ts b/packages/react-native/Libraries/Utilities/Platform.d.ts index 7f7dc61c104..b7252bd27c6 100644 --- a/packages/react-native/Libraries/Utilities/Platform.d.ts +++ b/packages/react-native/Libraries/Utilities/Platform.d.ts @@ -94,6 +94,7 @@ interface PlatformWindowsOSStatic extends PlatformStatic { interface PlatformWebStatic extends PlatformStatic { OS: 'web'; + Version: string; } export type Platform = diff --git a/packages/react-native/Libraries/Utilities/PlatformTypes.js b/packages/react-native/Libraries/Utilities/PlatformTypes.js index 3794b8b5e5e..40755e5ad5a 100644 --- a/packages/react-native/Libraries/Utilities/PlatformTypes.js +++ b/packages/react-native/Libraries/Utilities/PlatformTypes.js @@ -162,7 +162,7 @@ type MacOSPlatform = { type WebPlatform = { OS: 'web', // $FlowFixMe[unsafe-getters-setters] - get Version(): void, + get Version(): string, // $FlowFixMe[unsafe-getters-setters] get constants(): { reactNativeVersion: { diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index d21b62c9d14..5331b47e74f 100644 --- a/packages/react-native/ReactNativeApi.d.ts +++ b/packages/react-native/ReactNativeApi.d.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<1f77cd57f1bd57ae59c61a1cc6a58d81>> + * @generated SignedSource<<9e1f5e0432c20ddc070ec9dced982591>> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -5860,7 +5860,7 @@ declare type WebPlatform = { get isDisableAnimations(): boolean get isTesting(): boolean get isTV(): boolean - get Version(): void + get Version(): string } declare type WindowsPlatform = { OS: "windows"