Skip to content

Commit b44984a

Browse files
gengjiawentimdorr
authored andcommitted
use prettier format ts too (#3147)
* use prettier format ts too * use short matcher * fix extension match * add index.d.ts to format list
1 parent 648d06d commit b44984a

File tree

7 files changed

+315
-199
lines changed

7 files changed

+315
-199
lines changed

index.d.ts

Lines changed: 147 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/**
32
* An *action* is a plain object that represents an intention to change the
43
* state. Actions are the only way to get data into the store. Any data,
@@ -17,7 +16,7 @@
1716
* @template T the type of the action's `type` tag.
1817
*/
1918
export interface Action<T = any> {
20-
type: T;
19+
type: T
2120
}
2221

2322
/**
@@ -27,7 +26,7 @@ export interface Action<T = any> {
2726
*/
2827
export interface AnyAction extends Action {
2928
// Allows any extra properties to be defined in an action.
30-
[extraProps: string]: any;
29+
[extraProps: string]: any
3130
}
3231

3332
/* reducers */
@@ -56,15 +55,18 @@ export interface AnyAction extends Action {
5655
* @template S The type of state consumed and produced by this reducer.
5756
* @template A The type of actions the reducer can potentially respond to.
5857
*/
59-
export type Reducer<S = any, A extends Action = AnyAction> = (state: S | undefined, action: A) => S;
58+
export type Reducer<S = any, A extends Action = AnyAction> = (
59+
state: S | undefined,
60+
action: A
61+
) => S
6062

6163
/**
6264
* Object whose values correspond to different reducer functions.
6365
*
6466
* @template A The type of actions the reducers can potentially respond to.
6567
*/
6668
export type ReducersMapObject<S = any, A extends Action = Action> = {
67-
[K in keyof S]: Reducer<S[K], A>;
69+
[K in keyof S]: Reducer<S[K], A>
6870
}
6971

7072
/**
@@ -85,9 +87,12 @@ export type ReducersMapObject<S = any, A extends Action = Action> = {
8587
* @returns A reducer function that invokes every reducer inside the passed
8688
* object, and builds a state object with the same shape.
8789
*/
88-
export function combineReducers<S>(reducers: ReducersMapObject<S, any>): Reducer<S>;
89-
export function combineReducers<S, A extends Action = AnyAction>(reducers: ReducersMapObject<S, A>): Reducer<S, A>;
90-
90+
export function combineReducers<S>(
91+
reducers: ReducersMapObject<S, any>
92+
): Reducer<S>
93+
export function combineReducers<S, A extends Action = AnyAction>(
94+
reducers: ReducersMapObject<S, A>
95+
): Reducer<S, A>
9196

9297
/* store */
9398

@@ -113,14 +118,14 @@ export function combineReducers<S, A extends Action = AnyAction>(reducers: Reduc
113118
* dispatched.
114119
*/
115120
export interface Dispatch<A extends Action = AnyAction> {
116-
<T extends A>(action: T): T;
121+
<T extends A>(action: T): T
117122
}
118123

119124
/**
120125
* Function to remove listener added by `Store.subscribe()`.
121126
*/
122127
export interface Unsubscribe {
123-
(): void;
128+
(): void
124129
}
125130

126131
/**
@@ -158,14 +163,14 @@ export interface Store<S = any, A extends Action = AnyAction> {
158163
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
159164
* return something else (for example, a Promise you can await).
160165
*/
161-
dispatch: Dispatch<A>;
166+
dispatch: Dispatch<A>
162167

163168
/**
164169
* Reads the state tree managed by the store.
165170
*
166171
* @returns The current state tree of your application.
167172
*/
168-
getState(): S;
173+
getState(): S
169174

170175
/**
171176
* Adds a change listener. It will be called any time an action is
@@ -191,7 +196,7 @@ export interface Store<S = any, A extends Action = AnyAction> {
191196
* @param listener A callback to be invoked on every dispatch.
192197
* @returns A function to remove this change listener.
193198
*/
194-
subscribe(listener: () => void): Unsubscribe;
199+
subscribe(listener: () => void): Unsubscribe
195200

196201
/**
197202
* Replaces the reducer currently used by the store to calculate the state.
@@ -202,10 +207,10 @@ export interface Store<S = any, A extends Action = AnyAction> {
202207
*
203208
* @param nextReducer The reducer for the store to use instead.
204209
*/
205-
replaceReducer(nextReducer: Reducer<S, A>): void;
210+
replaceReducer(nextReducer: Reducer<S, A>): void
206211
}
207212

208-
export type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
213+
export type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> }
209214

210215
/**
211216
* A store creator is a function that creates a Redux store. Like with
@@ -219,8 +224,15 @@ export type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
219224
* @template StateExt State extension that is mixed into the state type.
220225
*/
221226
export interface StoreCreator {
222-
<S, A extends Action, Ext, StateExt>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S & StateExt, A> & Ext;
223-
<S, A extends Action, Ext, StateExt>(reducer: Reducer<S, A>, preloadedState?: DeepPartial<S>, enhancer?: StoreEnhancer<Ext>): Store<S & StateExt, A> & Ext;
227+
<S, A extends Action, Ext, StateExt>(
228+
reducer: Reducer<S, A>,
229+
enhancer?: StoreEnhancer<Ext, StateExt>
230+
): Store<S & StateExt, A> & Ext
231+
<S, A extends Action, Ext, StateExt>(
232+
reducer: Reducer<S, A>,
233+
preloadedState?: DeepPartial<S>,
234+
enhancer?: StoreEnhancer<Ext>
235+
): Store<S & StateExt, A> & Ext
224236
}
225237

226238
/**
@@ -251,7 +263,7 @@ export interface StoreCreator {
251263
* @returns A Redux store that lets you read the state, dispatch actions and
252264
* subscribe to changes.
253265
*/
254-
export const createStore: StoreCreator;
266+
export const createStore: StoreCreator
255267

256268
/**
257269
* A store enhancer is a higher-order function that composes a store creator
@@ -274,15 +286,22 @@ export const createStore: StoreCreator;
274286
* @template Ext Store extension that is mixed into the Store type.
275287
* @template StateExt State extension that is mixed into the state type.
276288
*/
277-
export type StoreEnhancer<Ext = {}, StateExt = {}> = (next: StoreEnhancerStoreCreator) => StoreEnhancerStoreCreator<Ext, StateExt>;
278-
export type StoreEnhancerStoreCreator<Ext = {}, StateExt = {}> = <S = any, A extends Action = AnyAction>(reducer: Reducer<S, A>, preloadedState?: DeepPartial<S>) => Store<S & StateExt, A> & Ext;
279-
289+
export type StoreEnhancer<Ext = {}, StateExt = {}> = (
290+
next: StoreEnhancerStoreCreator
291+
) => StoreEnhancerStoreCreator<Ext, StateExt>
292+
export type StoreEnhancerStoreCreator<Ext = {}, StateExt = {}> = <
293+
S = any,
294+
A extends Action = AnyAction
295+
>(
296+
reducer: Reducer<S, A>,
297+
preloadedState?: DeepPartial<S>
298+
) => Store<S & StateExt, A> & Ext
280299

281300
/* middleware */
282301

283302
export interface MiddlewareAPI<D extends Dispatch = Dispatch, S = any> {
284-
dispatch: D;
285-
getState(): S;
303+
dispatch: D
304+
getState(): S
286305
}
287306

288307
/**
@@ -299,8 +318,14 @@ export interface MiddlewareAPI<D extends Dispatch = Dispatch, S = any> {
299318
* @template D The type of Dispatch of the store where this middleware is
300319
* installed.
301320
*/
302-
export interface Middleware<DispatchExt = {}, S = any, D extends Dispatch = Dispatch> {
303-
(api: MiddlewareAPI<D, S>): (next: Dispatch<AnyAction>) => (action: any) => any;
321+
export interface Middleware<
322+
DispatchExt = {},
323+
S = any,
324+
D extends Dispatch = Dispatch
325+
> {
326+
(api: MiddlewareAPI<D, S>): (
327+
next: Dispatch<AnyAction>
328+
) => (action: any) => any
304329
}
305330

306331
/**
@@ -323,14 +348,35 @@ export interface Middleware<DispatchExt = {}, S = any, D extends Dispatch = Disp
323348
* @template Ext Dispatch signature added by a middleware.
324349
* @template S The type of the state supported by a middleware.
325350
*/
326-
export function applyMiddleware(): StoreEnhancer;
327-
export function applyMiddleware<Ext1, S>(middleware1: Middleware<Ext1, S, any>): StoreEnhancer<{dispatch: Ext1}>;
328-
export function applyMiddleware<Ext1, Ext2, S>(middleware1: Middleware<Ext1, S, any>, middleware2: Middleware<Ext2, S, any>): StoreEnhancer<{dispatch: Ext1 & Ext2}>;
329-
export function applyMiddleware<Ext1, Ext2, Ext3, S>(middleware1: Middleware<Ext1, S, any>, middleware2: Middleware<Ext2, S, any>, middleware3: Middleware<Ext3, S, any>): StoreEnhancer<{dispatch: Ext1 & Ext2 & Ext3}>;
330-
export function applyMiddleware<Ext1, Ext2, Ext3, Ext4, S>(middleware1: Middleware<Ext1, S, any>, middleware2: Middleware<Ext2, S, any>, middleware3: Middleware<Ext3, S, any>, middleware4: Middleware<Ext4, S, any>): StoreEnhancer<{dispatch: Ext1 & Ext2 & Ext3 & Ext4}>;
331-
export function applyMiddleware<Ext1, Ext2, Ext3, Ext4, Ext5, S>(middleware1: Middleware<Ext1, S, any>, middleware2: Middleware<Ext2, S, any>, middleware3: Middleware<Ext3, S, any>, middleware4: Middleware<Ext4, S, any>, middleware5: Middleware<Ext5, S, any>): StoreEnhancer<{dispatch: Ext1 & Ext2 & Ext3 & Ext4 & Ext5}>;
332-
export function applyMiddleware<Ext, S = any>(...middlewares: Middleware<any, S, any>[]): StoreEnhancer<{dispatch: Ext}>;
333-
351+
export function applyMiddleware(): StoreEnhancer
352+
export function applyMiddleware<Ext1, S>(
353+
middleware1: Middleware<Ext1, S, any>
354+
): StoreEnhancer<{ dispatch: Ext1 }>
355+
export function applyMiddleware<Ext1, Ext2, S>(
356+
middleware1: Middleware<Ext1, S, any>,
357+
middleware2: Middleware<Ext2, S, any>
358+
): StoreEnhancer<{ dispatch: Ext1 & Ext2 }>
359+
export function applyMiddleware<Ext1, Ext2, Ext3, S>(
360+
middleware1: Middleware<Ext1, S, any>,
361+
middleware2: Middleware<Ext2, S, any>,
362+
middleware3: Middleware<Ext3, S, any>
363+
): StoreEnhancer<{ dispatch: Ext1 & Ext2 & Ext3 }>
364+
export function applyMiddleware<Ext1, Ext2, Ext3, Ext4, S>(
365+
middleware1: Middleware<Ext1, S, any>,
366+
middleware2: Middleware<Ext2, S, any>,
367+
middleware3: Middleware<Ext3, S, any>,
368+
middleware4: Middleware<Ext4, S, any>
369+
): StoreEnhancer<{ dispatch: Ext1 & Ext2 & Ext3 & Ext4 }>
370+
export function applyMiddleware<Ext1, Ext2, Ext3, Ext4, Ext5, S>(
371+
middleware1: Middleware<Ext1, S, any>,
372+
middleware2: Middleware<Ext2, S, any>,
373+
middleware3: Middleware<Ext3, S, any>,
374+
middleware4: Middleware<Ext4, S, any>,
375+
middleware5: Middleware<Ext5, S, any>
376+
): StoreEnhancer<{ dispatch: Ext1 & Ext2 & Ext3 & Ext4 & Ext5 }>
377+
export function applyMiddleware<Ext, S = any>(
378+
...middlewares: Middleware<any, S, any>[]
379+
): StoreEnhancer<{ dispatch: Ext }>
334380

335381
/* action creators */
336382

@@ -352,14 +398,14 @@ export function applyMiddleware<Ext, S = any>(...middlewares: Middleware<any, S,
352398
* @template A Returned action type.
353399
*/
354400
export interface ActionCreator<A> {
355-
(...args: any[]): A;
401+
(...args: any[]): A
356402
}
357403

358404
/**
359405
* Object whose values are action creator functions.
360406
*/
361407
export interface ActionCreatorsMapObject<A = any> {
362-
[key: string]: ActionCreator<A>;
408+
[key: string]: ActionCreator<A>
363409
}
364410

365411
/**
@@ -381,27 +427,32 @@ export interface ActionCreatorsMapObject<A = any> {
381427
* creator wrapped into the `dispatch` call. If you passed a function as
382428
* `actionCreator`, the return value will also be a single function.
383429
*/
384-
export function bindActionCreators<A, C extends ActionCreator<A>>(actionCreator: C, dispatch: Dispatch): C;
430+
export function bindActionCreators<A, C extends ActionCreator<A>>(
431+
actionCreator: C,
432+
dispatch: Dispatch
433+
): C
385434

386435
export function bindActionCreators<
387436
A extends ActionCreator<any>,
388437
B extends ActionCreator<any>
389-
>(actionCreator: A, dispatch: Dispatch): B;
438+
>(actionCreator: A, dispatch: Dispatch): B
390439

391-
export function bindActionCreators<A, M extends ActionCreatorsMapObject<A>>(actionCreators: M, dispatch: Dispatch): M;
440+
export function bindActionCreators<A, M extends ActionCreatorsMapObject<A>>(
441+
actionCreators: M,
442+
dispatch: Dispatch
443+
): M
392444

393445
export function bindActionCreators<
394446
M extends ActionCreatorsMapObject<any>,
395447
N extends ActionCreatorsMapObject<any>
396-
>(actionCreators: M, dispatch: Dispatch): N;
397-
448+
>(actionCreators: M, dispatch: Dispatch): N
398449

399450
/* compose */
400451

401-
type Func0<R> = () => R;
402-
type Func1<T1, R> = (a1: T1) => R;
403-
type Func2<T1, T2, R> = (a1: T1, a2: T2) => R;
404-
type Func3<T1, T2, T3, R> = (a1: T1, a2: T2, a3: T3, ...args: any[]) => R;
452+
type Func0<R> = () => R
453+
type Func1<T1, R> = (a1: T1) => R
454+
type Func2<T1, T2, R> = (a1: T1, a2: T2) => R
455+
type Func3<T1, T2, T3, R> = (a1: T1, a2: T2, a3: T3, ...args: any[]) => R
405456

406457
/**
407458
* Composes single-argument functions from right to left. The rightmost
@@ -413,55 +464,77 @@ type Func3<T1, T2, T3, R> = (a1: T1, a2: T2, a3: T3, ...args: any[]) => R;
413464
* to left. For example, `compose(f, g, h)` is identical to doing
414465
* `(...args) => f(g(h(...args)))`.
415466
*/
416-
export function compose(): <R>(a: R) => R;
467+
export function compose(): <R>(a: R) => R
417468

418-
export function compose<F extends Function>(f: F): F;
469+
export function compose<F extends Function>(f: F): F
419470

420471
/* two functions */
421-
export function compose<A, R>(
422-
f1: (b: A) => R, f2: Func0<A>
423-
): Func0<R>;
472+
export function compose<A, R>(f1: (b: A) => R, f2: Func0<A>): Func0<R>
424473
export function compose<A, T1, R>(
425-
f1: (b: A) => R, f2: Func1<T1, A>
426-
): Func1<T1, R>;
474+
f1: (b: A) => R,
475+
f2: Func1<T1, A>
476+
): Func1<T1, R>
427477
export function compose<A, T1, T2, R>(
428-
f1: (b: A) => R, f2: Func2<T1, T2, A>
429-
): Func2<T1, T2, R>;
478+
f1: (b: A) => R,
479+
f2: Func2<T1, T2, A>
480+
): Func2<T1, T2, R>
430481
export function compose<A, T1, T2, T3, R>(
431-
f1: (b: A) => R, f2: Func3<T1, T2, T3, A>
432-
): Func3<T1, T2, T3, R>;
482+
f1: (b: A) => R,
483+
f2: Func3<T1, T2, T3, A>
484+
): Func3<T1, T2, T3, R>
433485

434486
/* three functions */
435487
export function compose<A, B, R>(
436-
f1: (b: B) => R, f2: (a: A) => B, f3: Func0<A>
437-
): Func0<R>;
488+
f1: (b: B) => R,
489+
f2: (a: A) => B,
490+
f3: Func0<A>
491+
): Func0<R>
438492
export function compose<A, B, T1, R>(
439-
f1: (b: B) => R, f2: (a: A) => B, f3: Func1<T1, A>
440-
): Func1<T1, R>;
493+
f1: (b: B) => R,
494+
f2: (a: A) => B,
495+
f3: Func1<T1, A>
496+
): Func1<T1, R>
441497
export function compose<A, B, T1, T2, R>(
442-
f1: (b: B) => R, f2: (a: A) => B, f3: Func2<T1, T2, A>
443-
): Func2<T1, T2, R>;
498+
f1: (b: B) => R,
499+
f2: (a: A) => B,
500+
f3: Func2<T1, T2, A>
501+
): Func2<T1, T2, R>
444502
export function compose<A, B, T1, T2, T3, R>(
445-
f1: (b: B) => R, f2: (a: A) => B, f3: Func3<T1, T2, T3, A>
446-
): Func3<T1, T2, T3, R>;
503+
f1: (b: B) => R,
504+
f2: (a: A) => B,
505+
f3: Func3<T1, T2, T3, A>
506+
): Func3<T1, T2, T3, R>
447507

448508
/* four functions */
449509
export function compose<A, B, C, R>(
450-
f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B, f4: Func0<A>
451-
): Func0<R>;
510+
f1: (b: C) => R,
511+
f2: (a: B) => C,
512+
f3: (a: A) => B,
513+
f4: Func0<A>
514+
): Func0<R>
452515
export function compose<A, B, C, T1, R>(
453-
f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B, f4: Func1<T1, A>
454-
): Func1<T1, R>;
516+
f1: (b: C) => R,
517+
f2: (a: B) => C,
518+
f3: (a: A) => B,
519+
f4: Func1<T1, A>
520+
): Func1<T1, R>
455521
export function compose<A, B, C, T1, T2, R>(
456-
f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B, f4: Func2<T1, T2, A>
457-
): Func2<T1, T2, R>;
522+
f1: (b: C) => R,
523+
f2: (a: B) => C,
524+
f3: (a: A) => B,
525+
f4: Func2<T1, T2, A>
526+
): Func2<T1, T2, R>
458527
export function compose<A, B, C, T1, T2, T3, R>(
459-
f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B, f4: Func3<T1, T2, T3, A>
460-
): Func3<T1, T2, T3, R>;
528+
f1: (b: C) => R,
529+
f2: (a: B) => C,
530+
f3: (a: A) => B,
531+
f4: Func3<T1, T2, T3, A>
532+
): Func3<T1, T2, T3, R>
461533

462534
/* rest */
463535
export function compose<R>(
464-
f1: (b: any) => R, ...funcs: Function[]
465-
): (...args: any[]) => R;
536+
f1: (b: any) => R,
537+
...funcs: Function[]
538+
): (...args: any[]) => R
466539

467-
export function compose<R>(...funcs: Function[]): (...args: any[]) => R;
540+
export function compose<R>(...funcs: Function[]): (...args: any[]) => R

0 commit comments

Comments
 (0)