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

remove cross type reference by direct import, fix broken tests #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
import type { Reducer, Store } from "redux";

declare module "redux-oidc" {
/**
* S = State
* A = Action
* D = Dispatch
*
* Below type definitions are copied from redux_v4.x.x.js
* The issue is that flow will silenty cast cross referenced types to any, end up losing type information
* except for those builtin ones.
* ticket discussing this issue https://github.com/flow-typed/flow-typed/issues/1857
* also mentioned here not to do it! https://github.com/flow-typed/flow-typed/blob/master/CONTRIBUTING.md#dont-import-types-from-other-libdefs
*/
declare type DispatchAPI<A> = (action: A) => A;

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

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

declare type Store<S, A, D = Dispatch<A>> = {
// rewrite MiddlewareAPI members in order to get nicer error messages (intersections produce long messages)
dispatch: D,
getState(): S,
subscribe(listener: () => void): () => void,
replaceReducer(nextReducer: Reducer<S, A>): void,
...
};
// end of copied types

declare type UserManager = {
getUser: () => Promise<User<*>>,
removeUser: () => Promise<*>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
import type { Reducer, Store } from "redux";

declare module "redux-oidc" {

/**
* S = State
* A = Action
* D = Dispatch
*
* Below type definitions are copied from redux_v4.x.x.js
* The issue is that flow will silenty cast cross referenced types to any, end up losing type information
* except for those builtin ones.
* ticket discussing this issue https://github.com/flow-typed/flow-typed/issues/1857
* also mentioned here not to do it! https://github.com/flow-typed/flow-typed/blob/master/CONTRIBUTING.md#dont-import-types-from-other-libdefs
*/
declare type DispatchAPI<A> = (action: A) => A;

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

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

declare type Store<S, A, D = Dispatch<A>> = {
// rewrite MiddlewareAPI members in order to get nicer error messages (intersections produce long messages)
dispatch: D,
getState(): S,
subscribe(listener: () => void): () => void,
replaceReducer(nextReducer: Reducer<S, A>): void,
...
};
// end of copied types

declare type UserManager = {
getUser: () => Promise<User<*>>,
removeUser: () => Promise<*>,
Expand Down