-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
Hi,
I am trying to create a "middleware" api, in redux, which already has a bunch of built-in types. And I am trying to use existing types to create a new middleware. But flow is throwing this error to me:
store.dispatch({ type: 'string' });
^ object literal. This type is incompatible with the expected param type of
14: return (store: MiddlewareAPI<S, A>) => next => (action: A) => {
^ some incompatible instantiation of `A`
When I am trying to do:
/* @flow */
declare type DispatchAPI<A> = (action: A) => A;
declare type Dispatch<A: { type: $Subtype<string> }> = DispatchAPI<A>;
declare type MiddlewareAPI<S, A, D = Dispatch<A>> = {
dispatch: D;
getState(): S;
};
type Middleware<S, A, D = Dispatch<A>> =
(api: MiddlewareAPI<S, A, D>) =>
(next: D) => D;
export const createSSRMiddleware = <S, A: { type: string }>(): Middleware<S, A> => {
return (store: MiddlewareAPI<S, A>) => next => (action: A) => {
store.dispatch({ type: 'string' });
return next(action);
};
};Below is the link to reproduce the issue:
I also found out that even with a simple case like:
/* @flow */
const foo = <A: number>() => {
const bar: A = 1;
}It also producing the same error, I don't know if they are related. But looks like it's the case.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels