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:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[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
This commit is contained in:
riteshshukla04
2025-08-14 09:02:43 -07:00
committed by Facebook GitHub Bot
parent 56ad53cb14
commit f6ba2dbf3b
3 changed files with 4 additions and 3 deletions
@@ -94,6 +94,7 @@ interface PlatformWindowsOSStatic extends PlatformStatic {
interface PlatformWebStatic extends PlatformStatic {
OS: 'web';
Version: string;
}
export type Platform =
+1 -1
View File
@@ -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: {
+2 -2
View File
@@ -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"