Bug 1626508 - Part 2: Add flow-typed definitions for Redux v4. r=jlast

Depends on D69156

Differential Revision: https://phabricator.services.mozilla.com/D69157

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Logan Smyth 2020-04-01 16:42:06 +00:00
Родитель 64797343f8
Коммит 077832ce70
6 изменённых файлов: 145 добавлений и 10 удалений

100
devtools/client/debugger/flow-typed/npm/redux_v4.x.x.js поставляемый Normal file
Просмотреть файл

@ -0,0 +1,100 @@
// flow-typed signature: 99b2d8ebd0ab4be20976dc62a3bbf54c
// flow-typed version: c6154227d1/redux_v4.x.x/flow_>=v0.89.x <=v0.103.x
declare module 'redux' {
/*
S = State
A = Action
D = Dispatch
*/
declare export type Action<T> = {
type: T
}
declare export type DispatchAPI<A> = (action: A) => A;
declare export type Dispatch<A: { type: * }> = DispatchAPI<A>;
declare export type MiddlewareAPI<S, A, D = Dispatch<A>> = {
dispatch: D,
getState(): S,
};
declare export 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,
};
declare export type Reducer<S, A> = (state: S | void, action: A) => S;
declare export type CombinedReducer<S, A> = (
state: ($Shape<S> & {}) | void,
action: A
) => S;
declare export type Middleware<S, A, D = Dispatch<A>> = (
api: MiddlewareAPI<S, A, D>
) => (next: D) => D;
declare export type StoreCreator<S, A, D = Dispatch<A>> = {
(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>,
(
reducer: Reducer<S, A>,
preloadedState: S,
enhancer?: StoreEnhancer<S, A, D>
): Store<S, A, D>,
};
declare export type StoreEnhancer<S, A, D = Dispatch<A>> = (
next: StoreCreator<S, A, D>
) => StoreCreator<S, A, D>;
declare export function createStore<S, A, D>(
reducer: Reducer<S, A>,
enhancer?: StoreEnhancer<S, A, D>
): Store<S, A, D>;
declare export function createStore<S, A, D>(
reducer: Reducer<S, A>,
preloadedState?: S,
enhancer?: StoreEnhancer<S, A, D>
): Store<S, A, D>;
declare export function applyMiddleware<S, A, D>(
...middlewares: Array<Middleware<S, A, D>>
): StoreEnhancer<S, A, D>;
declare export type ActionCreator<A, B> = (...args: Array<B>) => A;
declare export type ActionCreators<K, A> = {
[key: K]: ActionCreator<A, any>,
};
declare export function bindActionCreators<
A,
C: ActionCreator<A, any>,
D: DispatchAPI<A>
>(
actionCreator: C,
dispatch: D
): C;
declare export function bindActionCreators<
A,
K,
C: ActionCreators<K, A>,
D: DispatchAPI<A>
>(
actionCreators: C,
dispatch: D
): C;
declare export function combineReducers<O: {}, A>(
reducers: O
): CombinedReducer<$ObjMap<O, <S>(r: Reducer<S, any>) => S>, A>;
declare export var compose: $Compose;
}

Просмотреть файл

@ -74,6 +74,7 @@
"react-dom": "16.8.6",
"react-redux": "^5.0.7",
"react-transition-group": "^2.2.1",
"redux": "4.0.5",
"reselect": "^4.0.0",
"svg-inline-react": "^3.0.0",
"wasmparser": "^0.10.0",
@ -100,10 +101,10 @@
"author": "Jason Laster <jlaster@mozilla.com>",
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
"@babel/plugin-transform-modules-commonjs": "^7.5.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
"@babel/plugin-transform-modules-commonjs": "^7.5.0",
"@babel/preset-env": "^7.5.5",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",

Просмотреть файл

@ -11,7 +11,7 @@
* @module utils/create-store
*/
import { createStore, applyMiddleware } from "redux";
import { createStore, applyMiddleware, type StoreCreator } from "redux";
import { waitUntilService } from "./middleware/wait-service";
import { log } from "./middleware/log";
import { history } from "./middleware/history";
@ -45,8 +45,10 @@ type ReduxStoreOptions = {
* @memberof utils/create-store
* @static
*/
const configureStore = (opts: ReduxStoreOptions = {}) => {
const middleware = [
const configureStore = (
opts: ReduxStoreOptions = {}
): StoreCreator<any, any, any> => {
const middleware: any = [
thunk(opts.makeThunkArgs),
context,
promise,

Просмотреть файл

@ -23,6 +23,7 @@ import type { SourceActorsState } from "./source-actors";
import type { TabsState } from "./tabs";
import type { UIState } from "./ui";
import type { QuickOpenState } from "./quick-open";
import type { SourceTreeState } from "./source-tree";
import type { EventListenersState } from "./event-listeners";
import type { URL } from "../types";
@ -39,6 +40,7 @@ export type State = {
projectTextSearch: ProjectTextSearchState,
sources: SourcesState,
sourceActors: SourceActorsState,
sourceTree: SourceTreeState,
tabs: TabsState,
ui: UIState,
quickOpen: QuickOpenState,

Просмотреть файл

@ -9,7 +9,7 @@
* @module utils/test-head
*/
import { combineReducers } from "redux";
import { combineReducers, type Store } from "redux";
import sourceMaps from "devtools-source-map";
import reducers from "../reducers";
import actions from "../actions";
@ -18,7 +18,25 @@ import { getHistory } from "../test/utils/history";
import { parserWorker, evaluationsParser } from "../test/tests-setup";
import configureStore from "../actions/utils/create-store";
import sourceQueue from "../utils/source-queue";
import type { Source, OriginalSourceData, GeneratedSourceData } from "../types";
import type {
ThreadContext,
Source,
OriginalSourceData,
GeneratedSourceData,
} from "../types";
import type { State } from "../reducers/types";
import type { Action } from "../actions/types";
type TestStore = Store<State, Action, any> & {
thunkArgs: () => {
dispatch: any,
getState: () => State,
client: any,
sourceMaps: any,
panel: {||},
},
cx: ThreadContext,
};
/**
* This file contains older interfaces used by tests that have not been
@ -29,8 +47,12 @@ import type { Source, OriginalSourceData, GeneratedSourceData } from "../types";
* @memberof utils/test-head
* @static
*/
function createStore(client: any, initialState: any = {}, sourceMapsMock: any) {
const store = configureStore({
function createStore(
client: any,
initialState: any = {},
sourceMapsMock: any
): TestStore {
const store: any = configureStore({
log: false,
history: getHistory(),
makeThunkArgs: args => {

Просмотреть файл

@ -10220,6 +10220,14 @@ redux-logger@=3.0.6:
dependencies:
deep-diff "^0.3.5"
redux@4.0.5:
version "4.0.5"
resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.5.tgz#4db5de5816e17891de8a80c424232d06f051d93f"
integrity sha512-VSz1uMAH24DM6MF72vcojpYPtrTUu3ByVWfPL1nPfVRb5mZVTve5GnNCUV53QM/BZ66xfWrm0CTWoM+Xlz8V1w==
dependencies:
loose-envify "^1.4.0"
symbol-observable "^1.2.0"
redux@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/redux/-/redux-3.7.2.tgz#06b73123215901d25d065be342eb026bc1c8537b"
@ -11860,7 +11868,7 @@ svgo@^0.7.0:
sax "~1.2.1"
whet.extend "~0.9.9"
symbol-observable@^1.0.3, symbol-observable@^1.1.0:
symbol-observable@^1.0.3, symbol-observable@^1.1.0, symbol-observable@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"