Skip to content

Commit

Permalink
fix TSDoc comments (#3560)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedmao authored and timdorr committed Sep 5, 2019
1 parent 766f934 commit 9e71b4c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 deletions.
7 changes: 5 additions & 2 deletions src/applyMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ import { Reducer } from './types/reducers'
* Note that each middleware will be given the `dispatch` and `getState` functions
* as named arguments.
*
* @param {...Function} middlewares The middleware chain to be applied.
* @returns {Function} A store enhancer applying the middleware.
* @param middlewares The middleware chain to be applied.
* @returns A store enhancer applying the middleware.
*
* @template Ext Dispatch signature added by a middleware.
* @template S The type of the state supported by a middleware.
*/
export default function applyMiddleware(): StoreEnhancer
export default function applyMiddleware<Ext1, S>(
Expand Down
2 changes: 1 addition & 1 deletion src/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Func3<T1, T2, T3, R> = (a1: T1, a2: T2, a3: T3, ...args: any[]) => R
* resulting composite function.
*
* @param funcs The functions to compose.
* @returns R function obtained by composing the argument functions from right
* @returns A function obtained by composing the argument functions from right
* to left. For example, `compose(f, g, h)` is identical to doing
* `(...args) => f(g(h(...args)))`.
*/
Expand Down
28 changes: 14 additions & 14 deletions src/createStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ import isPlainObject from './utils/isPlainObject'
* parts of the state tree respond to actions, you may combine several reducers
* into a single reducer function by using `combineReducers`.
*
* @param {Function} reducer A function that returns the next state tree, given
* @param reducer A function that returns the next state tree, given
* the current state tree and the action to handle.
*
* @param {any} [preloadedState] The initial state. You may optionally specify it
* @param preloadedState The initial state. You may optionally specify it
* to hydrate the state from the server in universal apps, or to restore a
* previously serialized user session.
* If you use `combineReducers` to produce the root reducer function, this must be
* an object with the same shape as `combineReducers` keys.
*
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
* @param enhancer The store enhancer. You may optionally specify it
* to enhance the store with third-party capabilities such as middleware,
* time travel, persistence, etc. The only store enhancer that ships with Redux
* is `applyMiddleware()`.
*
* @returns {Store} A Redux store that lets you read the state, dispatch actions
* @returns A Redux store that lets you read the state, dispatch actions
* and subscribe to changes.
*/
export default function createStore<
Expand Down Expand Up @@ -119,7 +119,7 @@ export default function createStore<
/**
* Reads the state tree managed by the store.
*
* @returns {any} The current state tree of your application.
* @returns The current state tree of your application.
*/
function getState(): S {
if (isDispatching) {
Expand Down Expand Up @@ -153,8 +153,8 @@ export default function createStore<
* registered before the `dispatch()` started will be called with the latest
* state by the time it exits.
*
* @param {Function} listener A callback to be invoked on every dispatch.
* @returns {Function} A function to remove this change listener.
* @param listener A callback to be invoked on every dispatch.
* @returns A function to remove this change listener.
*/
function subscribe(listener: () => void) {
if (typeof listener !== 'function') {
Expand Down Expand Up @@ -210,13 +210,13 @@ export default function createStore<
* example, see the documentation for the `redux-thunk` package. Even the
* middleware will eventually dispatch plain object actions using this method.
*
* @param {Object} action A plain object representing “what changed”. It is
* @param action A plain object representing “what changed”. It is
* a good idea to keep actions serializable so you can record and replay user
* sessions, or use the time travelling `redux-devtools`. An action must have
* a `type` property which may not be `undefined`. It is a good idea to use
* string constants for action types.
*
* @returns {Object} For convenience, the same action object you dispatched.
* @returns For convenience, the same action object you dispatched.
*
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
* return something else (for example, a Promise you can await).
Expand Down Expand Up @@ -263,8 +263,8 @@ export default function createStore<
* load some of the reducers dynamically. You might also need this if you
* implement a hot reloading mechanism for Redux.
*
* @param {Function} nextReducer The reducer for the store to use instead.
* @returns {Store} The same store instance with a new reducer in place.
* @param nextReducer The reducer for the store to use instead.
* @returns The same store instance with a new reducer in place.
*/
function replaceReducer<NewState, NewActions extends A>(
nextReducer: Reducer<NewState, NewActions>
Expand Down Expand Up @@ -296,7 +296,7 @@ export default function createStore<

/**
* Interoperability point for observable/reactive libraries.
* @returns {observable} A minimal observable of state changes.
* @returns A minimal observable of state changes.
* For more information, see the observable proposal:
* https://github.com/tc39/proposal-observable
*/
Expand All @@ -305,9 +305,9 @@ export default function createStore<
return {
/**
* The minimal observable subscription method.
* @param {Object} observer Any object that can be used as an observer.
* @param observer Any object that can be used as an observer.
* The observer object should have a `next` method.
* @returns {subscription} An object with an `unsubscribe` method that can
* @returns An object with an `unsubscribe` method that can
* be used to unsubscribe the observable from the store, and prevent further
* emission of values from the observable.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/types/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface MiddlewareAPI<D extends Dispatch = Dispatch, S = any> {
* installed.
*/
export interface Middleware<
_DispatchExt = {}, // TODO: remove unused component
_DispatchExt = {}, // TODO: remove unused component (breaking change)
S = any,
D extends Dispatch = Dispatch
> {
Expand Down
6 changes: 3 additions & 3 deletions src/utils/isPlainObject.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @param {any} obj The object to inspect.
* @returns {boolean} True if the argument appears to be a plain object.
* @param obj The object to inspect.
* @returns True if the argument appears to be a plain object.
*/
export default function isPlainObject(obj: unknown) {
export default function isPlainObject(obj: any): boolean {
if (typeof obj !== 'object' || obj === null) return false

let proto = obj
Expand Down
5 changes: 2 additions & 3 deletions src/utils/warning.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/**
* Prints a warning in the console if it exists.
*
* @param {String} message The warning message.
* @returns {void}
* @param message The warning message.
*/
export default function warning(message: string) {
export default function warning(message: string): void {
/* eslint-disable no-console */
if (typeof console !== 'undefined' && typeof console.error === 'function') {
console.error(message)
Expand Down

0 comments on commit 9e71b4c

Please sign in to comment.