From b7f07473dfdfb09c2f4d3e6e5d4ff3fdc7506fee Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Fri, 14 Oct 2022 11:13:38 -0700 Subject: [PATCH] Improve the type of Platform.select for Android Summary: There's no need for the 3 type arguments here. Flow will infer a union already if multiple properties are provided. Worse, by not providing these properties these tvars end up with no bounds, which can cause downstream constraints to stall. All of the suppresisons added here are for legitimate errors that were uncovered by consolidating to one type argument. Changelog: [internal] Reviewed By: SamChou19815 Differential Revision: D40355811 fbshipit-source-id: 088fd087017a6082c793ef00c8810a81b39fb9fb --- Libraries/Utilities/Platform.android.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/Utilities/Platform.android.js b/Libraries/Utilities/Platform.android.js index 9dd53d84791..29234be81a7 100644 --- a/Libraries/Utilities/Platform.android.js +++ b/Libraries/Utilities/Platform.android.js @@ -10,10 +10,10 @@ import NativePlatformConstantsAndroid from './NativePlatformConstantsAndroid'; -export type PlatformSelectSpec = { - android?: A, - native?: N, - default?: D, +export type PlatformSelectSpec = { + android?: T, + native?: T, + default?: T, ... }; @@ -65,7 +65,7 @@ const Platform = { // $FlowFixMe[object-this-reference] return this.constants.uiMode === 'tv'; }, - select: (spec: PlatformSelectSpec): A | N | D => + select: (spec: PlatformSelectSpec): T => 'android' in spec ? // $FlowFixMe[incompatible-return] spec.android