diff --git a/keyserver/flow-typed/npm/react-redux_v7.x.x.js b/keyserver/flow-typed/npm/react-redux_v7.x.x.js --- a/keyserver/flow-typed/npm/react-redux_v7.x.x.js +++ b/keyserver/flow-typed/npm/react-redux_v7.x.x.js @@ -57,7 +57,7 @@ // and provide the StateProps type to the SP type parameter. | ((state: S, ownProps: OP) => (state: S, ownProps: OP) => SP); - declare type Bind = ((...A) => R) => (...A) => $Call; + declare type Bind = ((...A) => R) => (...A) => ReturnType; declare type MapDispatchToPropsFn = | ((dispatch: D, ownProps: OP) => DP) @@ -91,6 +91,13 @@ declare type MergeOPDP = {| ...$Exact, ...DP |}; declare type MergeOPSPDP = {| ...$Exact, ...SP, ...DP |}; + declare type MapDispatch = { + [K in $Keys]: + DP[K] extends (...args: infer A) => R + ? (...A) => ReturnType + : empty + }; + declare export function connect( mapStateToProps?: null | void, mapDispatchToProps?: null | void, @@ -123,7 +130,7 @@ mapDispatchToProps: DP, mergeProps?: null | void, options?: ?Options>, - ): Connector>>>; + ): Connector>>; declare export function connect( // If you get error here try adding return type to your mapStateToProps function @@ -139,7 +146,7 @@ mapDispatchToProps: DP, mergeProps?: null | void, options?: ?Options>, - ): Connector>>>; + ): Connector>>; // With `mergeProps` argument @@ -180,7 +187,7 @@ declare export function connect( mapStateToProps: null | void, mapDispatchToProps: DP, - mergeProps: MergeProps>>, + mergeProps: MergeProps}>, options?: ?Options, ): Connector; @@ -199,7 +206,7 @@ declare export function connect( mapStateToProps: MapStateToProps, mapDispatchToProps: DP, - mergeProps: MergeProps>>, + mergeProps: MergeProps}>, options?: ?Options, ): Connector; diff --git a/keyserver/flow-typed/npm/redux_v4.x.x.js b/keyserver/flow-typed/npm/redux_v4.x.x.js --- a/keyserver/flow-typed/npm/redux_v4.x.x.js +++ b/keyserver/flow-typed/npm/redux_v4.x.x.js @@ -97,7 +97,7 @@ ): C; declare export function combineReducers( - reducers: $ObjMap(V) => Reducer>, + reducers: {[K in keyof RootState]: Reducer} ): Reducer; declare function _compose(): (a: T) => T; diff --git a/lib/flow-typed/npm/react-redux_v7.x.x.js b/lib/flow-typed/npm/react-redux_v7.x.x.js --- a/lib/flow-typed/npm/react-redux_v7.x.x.js +++ b/lib/flow-typed/npm/react-redux_v7.x.x.js @@ -91,6 +91,13 @@ declare type MergeOPDP = {| ...$Exact, ...DP |}; declare type MergeOPSPDP = {| ...$Exact, ...SP, ...DP |}; + declare type MapDispatch = { + [K in $Keys]: + DP[K] extends (...args: infer A) => R + ? (...A) => ReturnType + : empty + }; + declare export function connect( mapStateToProps?: null | void, mapDispatchToProps?: null | void, @@ -123,7 +130,7 @@ mapDispatchToProps: DP, mergeProps?: null | void, options?: ?Options>, - ): Connector>>>; + ): Connector>>; declare export function connect( // If you get error here try adding return type to your mapStateToProps function @@ -139,7 +146,7 @@ mapDispatchToProps: DP, mergeProps?: null | void, options?: ?Options>, - ): Connector>>>; + ): Connector>>; // With `mergeProps` argument @@ -180,7 +187,7 @@ declare export function connect( mapStateToProps: null | void, mapDispatchToProps: DP, - mergeProps: MergeProps>>, + mergeProps: MergeProps}>, options?: ?Options, ): Connector; @@ -199,7 +206,7 @@ declare export function connect( mapStateToProps: MapStateToProps, mapDispatchToProps: DP, - mergeProps: MergeProps>>, + mergeProps: MergeProps}>, options?: ?Options, ): Connector; diff --git a/lib/flow-typed/npm/redux_v4.x.x.js b/lib/flow-typed/npm/redux_v4.x.x.js --- a/lib/flow-typed/npm/redux_v4.x.x.js +++ b/lib/flow-typed/npm/redux_v4.x.x.js @@ -97,7 +97,7 @@ ): C; declare export function combineReducers( - reducers: $ObjMap(V) => Reducer>, + reducers: {[K in keyof RootState]: Reducer} ): Reducer; declare function _compose(): (a: T) => T; diff --git a/lib/flow-typed/npm/reselect_v3.x.x.js b/lib/flow-typed/npm/reselect_v3.x.x.js --- a/lib/flow-typed/npm/reselect_v3.x.x.js +++ b/lib/flow-typed/npm/reselect_v3.x.x.js @@ -888,7 +888,7 @@ createStructuredSelector: }>( inputSelectors: InputSelectors, selectorCreator?: SelectorCreator - ) => OutputSelector> + ) => OutputSelector}> }; declare module.exports: Reselect; diff --git a/lib/flow-typed/npm/tcomb_v3.x.x.js b/lib/flow-typed/npm/tcomb_v3.x.x.js --- a/lib/flow-typed/npm/tcomb_v3.x.x.js +++ b/lib/flow-typed/npm/tcomb_v3.x.x.js @@ -86,7 +86,7 @@ declare type TypeToValidator = (v: V) => TType; - declare export type TStructProps<+T> = $ObjMap; + declare export type TStructProps<+T> = {[K in keyof T]: TType}; declare type TStructOptions = { name?: string, strict?: boolean, diff --git a/lib/shared/identity-client-context.js b/lib/shared/identity-client-context.js --- a/lib/shared/identity-client-context.js +++ b/lib/shared/identity-client-context.js @@ -12,11 +12,9 @@ export type PartialAuthMetadata = Partial; -// TODO: Replace this with mapped type after Flow upgrade -export type FullAuthMetadata = $ObjMap< - AuthMetadata, - (prop: T) => $NonMaybeType, ->; +export type FullAuthMetadata = { + [K in keyof AuthMetadata]: $NonMaybeType, +}; export type IdentityClientContextType = { +identityClient: IdentityServiceClient, diff --git a/lib/socket/inflight-requests.js b/lib/socket/inflight-requests.js --- a/lib/socket/inflight-requests.js +++ b/lib/socket/inflight-requests.js @@ -32,10 +32,11 @@ reject: (error: Error) => void, messageID: number, }; -type InflightRequestMap = $ObjMap< - ValidResponseMessageMap, - (T) => BaseInflightRequest<$Exact>, ->; +type InflightRequestMap = { + [K in keyof ValidResponseMessageMap]: BaseInflightRequest< + $Exact, + >, +}; type ValidResponseMessage = $Values; type InflightRequest = $Values; diff --git a/lib/types/subscription-types.js b/lib/types/subscription-types.js --- a/lib/types/subscription-types.js +++ b/lib/types/subscription-types.js @@ -10,10 +10,10 @@ pushNotifs: 'pushNotifs', }); -export type ThreadSubscription = $ObjMap< - typeof threadSubscriptions, - () => boolean, ->; +export type ThreadSubscription = { + // eslint-disable-next-line no-unused-vars + [K in keyof typeof threadSubscriptions]: boolean, +}; export const threadSubscriptionValidator: TInterface = tShape(_mapValues(() => t.Boolean)(threadSubscriptions)); diff --git a/lib/utils/promises.js b/lib/utils/promises.js --- a/lib/utils/promises.js +++ b/lib/utils/promises.js @@ -3,10 +3,13 @@ import sleep from './sleep.js'; type Promisable = Promise | T; +type PromiseAllResult = { + [K in keyof T]: T[K] extends Promisable ? U : T[K], +}; async function promiseAll }>( input: T, -): Promise<$ObjMap> { +): Promise> { const promises = []; const keys = Object.keys(input); for (let i = 0; i < keys.length; i++) { @@ -15,7 +18,7 @@ promises.push(promise); } const results = await Promise.all(promises); - const byName: { [string]: mixed } = {}; + const byName: PromiseAllResult = { ...input }; for (let i = 0; i < keys.length; i++) { const key = keys[i]; byName[key] = results[i]; diff --git a/native/flow-typed/npm/@react-navigation/core_v6.x.x.js b/native/flow-typed/npm/@react-navigation/core_v6.x.x.js --- a/native/flow-typed/npm/@react-navigation/core_v6.x.x.js +++ b/native/flow-typed/npm/@react-navigation/core_v6.x.x.js @@ -952,10 +952,7 @@ declare export type ScreenListeners< State: NavigationState = NavigationState, EventMap: EventMapBase = EventMapCore, - > = $ObjMapi< - {| [name: $Keys]: empty |}, - >(K, empty) => EventListenerCallback, - >; + > = {[K in $Keys]: EventListenerCallback}; declare type ScreenListenersProp< ScreenListenersParam: {...}, RouteParam, diff --git a/native/flow-typed/npm/react-native-reanimated_v2.x.x.js b/native/flow-typed/npm/react-native-reanimated_v2.x.x.js --- a/native/flow-typed/npm/react-native-reanimated_v2.x.x.js +++ b/native/flow-typed/npm/react-native-reanimated_v2.x.x.js @@ -519,7 +519,7 @@ declare type ToValue = (val: mixed) => ValueImpl; declare type Event = = $Event>( defs: $ReadOnlyArray<{ - +nativeEvent: Partial<$ObjMap>, + +nativeEvent: Partial<{[K in keyof E]: ValueImpl}>, ... }>, ) => EventResult; diff --git a/native/flow-typed/npm/react-redux_v7.x.x.js b/native/flow-typed/npm/react-redux_v7.x.x.js --- a/native/flow-typed/npm/react-redux_v7.x.x.js +++ b/native/flow-typed/npm/react-redux_v7.x.x.js @@ -91,6 +91,13 @@ declare type MergeOPDP = {| ...$Exact, ...DP |}; declare type MergeOPSPDP = {| ...$Exact, ...SP, ...DP |}; + declare type MapDispatch = { + [K in $Keys]: + DP[K] extends (...args: infer A) => R + ? (...A) => ReturnType + : empty + }; + declare export function connect( mapStateToProps?: null | void, mapDispatchToProps?: null | void, @@ -123,7 +130,7 @@ mapDispatchToProps: DP, mergeProps?: null | void, options?: ?Options>, - ): Connector>>>; + ): Connector>>; declare export function connect( // If you get error here try adding return type to your mapStateToProps function @@ -139,7 +146,7 @@ mapDispatchToProps: DP, mergeProps?: null | void, options?: ?Options>, - ): Connector>>>; + ): Connector>>; // With `mergeProps` argument @@ -180,7 +187,7 @@ declare export function connect( mapStateToProps: null | void, mapDispatchToProps: DP, - mergeProps: MergeProps>>, + mergeProps: MergeProps}>, options?: ?Options, ): Connector; @@ -199,7 +206,7 @@ declare export function connect( mapStateToProps: MapStateToProps, mapDispatchToProps: DP, - mergeProps: MergeProps>>, + mergeProps: MergeProps}>, options?: ?Options, ): Connector; diff --git a/native/flow-typed/npm/reselect_v3.x.x.js b/native/flow-typed/npm/reselect_v3.x.x.js --- a/native/flow-typed/npm/reselect_v3.x.x.js +++ b/native/flow-typed/npm/reselect_v3.x.x.js @@ -888,7 +888,7 @@ createStructuredSelector: }>( inputSelectors: InputSelectors, selectorCreator?: SelectorCreator - ) => OutputSelector> + ) => OutputSelector}> }; declare module.exports: Reselect; diff --git a/native/themes/colors.js b/native/themes/colors.js --- a/native/themes/colors.js +++ b/native/themes/colors.js @@ -286,8 +286,7 @@ type Styles = { [name: string]: { [field: string]: mixed } }; -type ReplaceField = (input: any) => any; -export type StyleSheetOf = $ReadOnly<$ObjMap>; +export type StyleSheetOf = $ReadOnly<{ [$Keys]: any }>; function stylesFromColors( obj: IS, diff --git a/web/flow-typed/npm/react-redux_v7.x.x.js b/web/flow-typed/npm/react-redux_v7.x.x.js --- a/web/flow-typed/npm/react-redux_v7.x.x.js +++ b/web/flow-typed/npm/react-redux_v7.x.x.js @@ -90,6 +90,13 @@ declare type MergeOPSP = {| ...$Exact, ...SP, dispatch: D |}; declare type MergeOPDP = {| ...$Exact, ...DP |}; declare type MergeOPSPDP = {| ...$Exact, ...SP, ...DP |}; + + declare type MapDispatch = { + [K in $Keys]: + DP[K] extends (...args: infer A) => R + ? (...A) => ReturnType + : empty + }; declare export function connect( mapStateToProps?: null | void, @@ -123,7 +130,7 @@ mapDispatchToProps: DP, mergeProps?: null | void, options?: ?Options>, - ): Connector>>>; + ): Connector>>; declare export function connect( // If you get error here try adding return type to your mapStateToProps function @@ -139,7 +146,7 @@ mapDispatchToProps: DP, mergeProps?: null | void, options?: ?Options>, - ): Connector>>>; + ): Connector>>; // With `mergeProps` argument @@ -180,7 +187,7 @@ declare export function connect( mapStateToProps: null | void, mapDispatchToProps: DP, - mergeProps: MergeProps>>, + mergeProps: MergeProps}>, options?: ?Options, ): Connector; @@ -199,7 +206,7 @@ declare export function connect( mapStateToProps: MapStateToProps, mapDispatchToProps: DP, - mergeProps: MergeProps>>, + mergeProps: MergeProps}>, options?: ?Options, ): Connector; diff --git a/web/flow-typed/npm/reselect_v3.x.x.js b/web/flow-typed/npm/reselect_v3.x.x.js --- a/web/flow-typed/npm/reselect_v3.x.x.js +++ b/web/flow-typed/npm/reselect_v3.x.x.js @@ -888,7 +888,7 @@ createStructuredSelector: }>( inputSelectors: InputSelectors, selectorCreator?: SelectorCreator - ) => OutputSelector> + ) => OutputSelector}> }; declare module.exports: Reselect;