Skip to content

Commit f6ba2db

Browse files
riteshshukla04facebook-github-bot
authored andcommitted
Add types for platform in React native web (#53216)
Summary: This PR fixes #52356. As per discussion here #52360 . We have changed the implementation in React native web in this PR necolas/react-native-web#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: #53216 Test Plan: N/A Reviewed By: christophpurrer Differential Revision: D80173301 Pulled By: necolas fbshipit-source-id: 750aae2427a6c36a068346a9722d9734d9906b58
1 parent 56ad53c commit f6ba2db

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

packages/react-native/Libraries/Utilities/Platform.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ interface PlatformWindowsOSStatic extends PlatformStatic {
9494

9595
interface PlatformWebStatic extends PlatformStatic {
9696
OS: 'web';
97+
Version: string;
9798
}
9899

99100
export type Platform =

packages/react-native/Libraries/Utilities/PlatformTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ type MacOSPlatform = {
162162
type WebPlatform = {
163163
OS: 'web',
164164
// $FlowFixMe[unsafe-getters-setters]
165-
get Version(): void,
165+
get Version(): string,
166166
// $FlowFixMe[unsafe-getters-setters]
167167
get constants(): {
168168
reactNativeVersion: {

packages/react-native/ReactNativeApi.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<1f77cd57f1bd57ae59c61a1cc6a58d81>>
7+
* @generated SignedSource<<9e1f5e0432c20ddc070ec9dced982591>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -5860,7 +5860,7 @@ declare type WebPlatform = {
58605860
get isDisableAnimations(): boolean
58615861
get isTesting(): boolean
58625862
get isTV(): boolean
5863-
get Version(): void
5863+
get Version(): string
58645864
}
58655865
declare type WindowsPlatform = {
58665866
OS: "windows"

0 commit comments

Comments
 (0)