From b60b70f7ce28c72ff81df1f1a42bd2cc6907c342 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Fri, 14 Oct 2022 08:39:26 -0700 Subject: [PATCH] Improve typings for Platform.select on iOS 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: D40355813 fbshipit-source-id: f02a101e5e32f3a2f660a34349e6416b9fde4124 --- Libraries/Utilities/Platform.ios.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/Utilities/Platform.ios.js b/Libraries/Utilities/Platform.ios.js index 07fd365d496..4adf4201c52 100644 --- a/Libraries/Utilities/Platform.ios.js +++ b/Libraries/Utilities/Platform.ios.js @@ -10,10 +10,10 @@ import NativePlatformConstantsIOS from './NativePlatformConstantsIOS'; -export type PlatformSelectSpec = { - default?: D, - native?: N, - ios?: I, +export type PlatformSelectSpec = { + default?: T, + native?: T, + ios?: T, ... }; @@ -65,7 +65,7 @@ const Platform = { } return false; }, - select: (spec: PlatformSelectSpec): D | N | I => + select: (spec: PlatformSelectSpec): T => // $FlowFixMe[incompatible-return] 'ios' in spec ? spec.ios : 'native' in spec ? spec.native : spec.default, };