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
This commit is contained in:
Jordan Brown
2022-10-14 08:39:26 -07:00
committed by Facebook GitHub Bot
parent 5d8a712fd5
commit b60b70f7ce
+5 -5
View File
@@ -10,10 +10,10 @@
import NativePlatformConstantsIOS from './NativePlatformConstantsIOS';
export type PlatformSelectSpec<D, N, I> = {
default?: D,
native?: N,
ios?: I,
export type PlatformSelectSpec<T> = {
default?: T,
native?: T,
ios?: T,
...
};
@@ -65,7 +65,7 @@ const Platform = {
}
return false;
},
select: <D, N, I>(spec: PlatformSelectSpec<D, N, I>): D | N | I =>
select: <T>(spec: PlatformSelectSpec<T>): T =>
// $FlowFixMe[incompatible-return]
'ios' in spec ? spec.ios : 'native' in spec ? spec.native : spec.default,
};