From 3d09b6f8507ea3b335ee7f8d8ee7443b5fb01ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Fri, 19 Jan 2024 10:19:38 -0800 Subject: [PATCH] fix: isVision return false for Platform.android.js (#42381) Summary: This PR is a follow up for https://github.com/facebook/react-native/issues/42243 it looks like we need to return `false` for the Platform.android.js to make flow happy. This is the error we were getting in `react-native-visionos` CI/CD: ![CleanShot 2024-01-19 at 13 01 19@2x](https://github.com/facebook/react-native/assets/52801365/218078b3-44d4-4dc0-bee7-f5d2e08eca50) ## Changelog: [INTERNAL] [FIXED] - Add `isVision` interface idiom for Platform.android.js Pull Request resolved: https://github.com/facebook/react-native/pull/42381 Test Plan: CI Green Reviewed By: cortinico Differential Revision: D52905993 Pulled By: NickGerleman fbshipit-source-id: 125d33b63e9114cb6276b554e426f32e0c406ea8 --- packages/react-native/Libraries/Utilities/Platform.android.js | 4 ++++ packages/react-native/Libraries/Utilities/Platform.flow.js | 2 ++ .../Libraries/__tests__/__snapshots__/public-api-test.js.snap | 1 + 3 files changed, 7 insertions(+) diff --git a/packages/react-native/Libraries/Utilities/Platform.android.js b/packages/react-native/Libraries/Utilities/Platform.android.js index 95210a315a2..5272465aa7c 100644 --- a/packages/react-native/Libraries/Utilities/Platform.android.js +++ b/packages/react-native/Libraries/Utilities/Platform.android.js @@ -69,6 +69,10 @@ const Platform: PlatformType = { // $FlowFixMe[object-this-reference] return this.constants.uiMode === 'tv'; }, + // $FlowFixMe[unsafe-getters-setters] + get isVision(): boolean { + return false; + }, select: (spec: PlatformSelectSpec): T => 'android' in spec ? // $FlowFixMe[incompatible-return] diff --git a/packages/react-native/Libraries/Utilities/Platform.flow.js b/packages/react-native/Libraries/Utilities/Platform.flow.js index cb5e56871aa..cfd7bbc71f8 100644 --- a/packages/react-native/Libraries/Utilities/Platform.flow.js +++ b/packages/react-native/Libraries/Utilities/Platform.flow.js @@ -80,6 +80,8 @@ type AndroidPlatform = { // $FlowFixMe[unsafe-getters-setters] get isTV(): boolean, // $FlowFixMe[unsafe-getters-setters] + get isVision(): boolean, + // $FlowFixMe[unsafe-getters-setters] get isTesting(): boolean, // $FlowFixMe[unsafe-getters-setters] get isDisableAnimations(): boolean, diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 1298282e9a1..1df66480be2 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -9940,6 +9940,7 @@ type AndroidPlatform = { Manufacturer: string, |}, get isTV(): boolean, + get isVision(): boolean, get isTesting(): boolean, get isDisableAnimations(): boolean, select: (spec: PlatformSelectSpec) => T,