Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark a bunch more object and array types read-only #5186

Merged
merged 10 commits into from
Jan 8, 2022
12 changes: 6 additions & 6 deletions flow-typed/redux_v4.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ declare module 'redux' {

declare export type DispatchAPI<A> = (action: A) => A;

declare export type Dispatch<A: { type: *, ... }> = DispatchAPI<A>;
declare export type Dispatch<A: { +type: mixed, ... }> = DispatchAPI<A>;

declare export type MiddlewareAPI<S, A, D = Dispatch<A>> = {|
dispatch: D,
Expand All @@ -32,7 +32,7 @@ declare module 'redux' {
replaceReducer(nextReducer: Reducer<S, A>): void,
|};

declare export type Reducer<S, A> = (state: S | void, action: A) => S;
declare export type Reducer<S, -A> = (state: S | void, action: A) => S;

declare export type CombinedReducer<S, A> = (
state: ($Shape<S> & { ... }) | void,
Expand Down Expand Up @@ -70,14 +70,14 @@ declare module 'redux' {
...middlewares: Array<Middleware<S, A, D>>
): StoreEnhancer<S, A, D>;

declare export type ActionCreator<A, B> = (...args: Array<B>) => A;
declare export type ActionCreator<A, -B> = (...args: $ReadOnlyArray<B>) => A;
declare export type ActionCreators<K, A> = {|
[key: K]: ActionCreator<A, any>,
[key: K]: ActionCreator<A, empty>,
|};

declare export function bindActionCreators<
A,
C: ActionCreator<A, any>,
C: ActionCreator<A, empty>,
D: DispatchAPI<A>
>(
actionCreator: C,
Expand All @@ -95,7 +95,7 @@ declare module 'redux' {

declare export function combineReducers<O: { ... }, A>(
reducers: O
): CombinedReducer<$ObjMap<O, <S>(r: Reducer<S, any>) => S>, A>;
): CombinedReducer<$ObjMap<O, <S>(r: Reducer<S, A>) => S>, A>;

declare export var compose: $Compose;
}
6 changes: 3 additions & 3 deletions src/__tests__/lib/exampleData.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ const randMessageId: () => number = makeUniqueRandInt('message ID', 10000000);
export const pmMessage = (args?: {|
...$Rest<PmMessage, { ... }>,
sender?: User,
recipients?: User[],
recipients?: $ReadOnlyArray<User>,
sender_id?: number, // accept a plain number, for convenience in tests
|}): PmMessage => {
// The `Object.freeze` is to work around a Flow issue:
Expand Down Expand Up @@ -395,7 +395,7 @@ export const pmMessage = (args?: {|

export const pmMessageFromTo = (
from: User,
to: User[],
to: $ReadOnlyArray<User>,
extra?: $Rest<PmMessage, { ... }>,
): PmMessage => pmMessage({ sender: from, recipients: [from, ...to], ...extra });

Expand Down Expand Up @@ -444,7 +444,7 @@ export const streamMessage = (args?: {|
};

/** Construct a MessagesState from a list of messages. */
export const makeMessagesState = (messages: Message[]): MessagesState =>
export const makeMessagesState = (messages: $ReadOnlyArray<Message>): MessagesState =>
Immutable.Map(messages.map(m => [m.id, m]));

/* ========================================================================
Expand Down
Loading