Skip to content

Commit 48de485

Browse files
jedmaotimdorr
authored andcommitted
fix TSDoc comments (reduxjs#3560)
1 parent 20c995c commit 48de485

File tree

6 files changed

+26
-24
lines changed

6 files changed

+26
-24
lines changed

src/applyMiddleware.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ import { Reducer } from './types/reducers'
1717
* Note that each middleware will be given the `dispatch` and `getState` functions
1818
* as named arguments.
1919
*
20-
* @param {...Function} middlewares The middleware chain to be applied.
21-
* @returns {Function} A store enhancer applying the middleware.
20+
* @param middlewares The middleware chain to be applied.
21+
* @returns A store enhancer applying the middleware.
22+
*
23+
* @template Ext Dispatch signature added by a middleware.
24+
* @template S The type of the state supported by a middleware.
2225
*/
2326
export default function applyMiddleware(): StoreEnhancer
2427
export default function applyMiddleware<Ext1, S>(

src/compose.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type Func3<T1, T2, T3, R> = (a1: T1, a2: T2, a3: T3, ...args: any[]) => R
99
* resulting composite function.
1010
*
1111
* @param funcs The functions to compose.
12-
* @returns R function obtained by composing the argument functions from right
12+
* @returns A function obtained by composing the argument functions from right
1313
* to left. For example, `compose(f, g, h)` is identical to doing
1414
* `(...args) => f(g(h(...args)))`.
1515
*/

src/createStore.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ import isPlainObject from './utils/isPlainObject'
2121
* parts of the state tree respond to actions, you may combine several reducers
2222
* into a single reducer function by using `combineReducers`.
2323
*
24-
* @param {Function} reducer A function that returns the next state tree, given
24+
* @param reducer A function that returns the next state tree, given
2525
* the current state tree and the action to handle.
2626
*
27-
* @param {any} [preloadedState] The initial state. You may optionally specify it
27+
* @param preloadedState The initial state. You may optionally specify it
2828
* to hydrate the state from the server in universal apps, or to restore a
2929
* previously serialized user session.
3030
* If you use `combineReducers` to produce the root reducer function, this must be
3131
* an object with the same shape as `combineReducers` keys.
3232
*
33-
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
33+
* @param enhancer The store enhancer. You may optionally specify it
3434
* to enhance the store with third-party capabilities such as middleware,
3535
* time travel, persistence, etc. The only store enhancer that ships with Redux
3636
* is `applyMiddleware()`.
3737
*
38-
* @returns {Store} A Redux store that lets you read the state, dispatch actions
38+
* @returns A Redux store that lets you read the state, dispatch actions
3939
* and subscribe to changes.
4040
*/
4141
export default function createStore<
@@ -119,7 +119,7 @@ export default function createStore<
119119
/**
120120
* Reads the state tree managed by the store.
121121
*
122-
* @returns {any} The current state tree of your application.
122+
* @returns The current state tree of your application.
123123
*/
124124
function getState(): S {
125125
if (isDispatching) {
@@ -153,8 +153,8 @@ export default function createStore<
153153
* registered before the `dispatch()` started will be called with the latest
154154
* state by the time it exits.
155155
*
156-
* @param {Function} listener A callback to be invoked on every dispatch.
157-
* @returns {Function} A function to remove this change listener.
156+
* @param listener A callback to be invoked on every dispatch.
157+
* @returns A function to remove this change listener.
158158
*/
159159
function subscribe(listener: () => void) {
160160
if (typeof listener !== 'function') {
@@ -210,13 +210,13 @@ export default function createStore<
210210
* example, see the documentation for the `redux-thunk` package. Even the
211211
* middleware will eventually dispatch plain object actions using this method.
212212
*
213-
* @param {Object} action A plain object representing “what changed”. It is
213+
* @param action A plain object representing “what changed”. It is
214214
* a good idea to keep actions serializable so you can record and replay user
215215
* sessions, or use the time travelling `redux-devtools`. An action must have
216216
* a `type` property which may not be `undefined`. It is a good idea to use
217217
* string constants for action types.
218218
*
219-
* @returns {Object} For convenience, the same action object you dispatched.
219+
* @returns For convenience, the same action object you dispatched.
220220
*
221221
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
222222
* return something else (for example, a Promise you can await).
@@ -263,8 +263,8 @@ export default function createStore<
263263
* load some of the reducers dynamically. You might also need this if you
264264
* implement a hot reloading mechanism for Redux.
265265
*
266-
* @param {Function} nextReducer The reducer for the store to use instead.
267-
* @returns {Store} The same store instance with a new reducer in place.
266+
* @param nextReducer The reducer for the store to use instead.
267+
* @returns The same store instance with a new reducer in place.
268268
*/
269269
function replaceReducer<NewState, NewActions extends A>(
270270
nextReducer: Reducer<NewState, NewActions>
@@ -296,7 +296,7 @@ export default function createStore<
296296

297297
/**
298298
* Interoperability point for observable/reactive libraries.
299-
* @returns {observable} A minimal observable of state changes.
299+
* @returns A minimal observable of state changes.
300300
* For more information, see the observable proposal:
301301
* https://github.com/tc39/proposal-observable
302302
*/
@@ -305,9 +305,9 @@ export default function createStore<
305305
return {
306306
/**
307307
* The minimal observable subscription method.
308-
* @param {Object} observer Any object that can be used as an observer.
308+
* @param observer Any object that can be used as an observer.
309309
* The observer object should have a `next` method.
310-
* @returns {subscription} An object with an `unsubscribe` method that can
310+
* @returns An object with an `unsubscribe` method that can
311311
* be used to unsubscribe the observable from the store, and prevent further
312312
* emission of values from the observable.
313313
*/

src/types/middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface MiddlewareAPI<D extends Dispatch = Dispatch, S = any> {
2121
* installed.
2222
*/
2323
export interface Middleware<
24-
_DispatchExt = {}, // TODO: remove unused component
24+
_DispatchExt = {}, // TODO: remove unused component (breaking change)
2525
S = any,
2626
D extends Dispatch = Dispatch
2727
> {

src/utils/isPlainObject.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* @param {any} obj The object to inspect.
3-
* @returns {boolean} True if the argument appears to be a plain object.
2+
* @param obj The object to inspect.
3+
* @returns True if the argument appears to be a plain object.
44
*/
5-
export default function isPlainObject(obj: unknown) {
5+
export default function isPlainObject(obj: any): boolean {
66
if (typeof obj !== 'object' || obj === null) return false
77

88
let proto = obj

src/utils/warning.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/**
22
* Prints a warning in the console if it exists.
33
*
4-
* @param {String} message The warning message.
5-
* @returns {void}
4+
* @param message The warning message.
65
*/
7-
export default function warning(message: string) {
6+
export default function warning(message: string): void {
87
/* eslint-disable no-console */
98
if (typeof console !== 'undefined' && typeof console.error === 'function') {
109
console.error(message)

0 commit comments

Comments
 (0)