diff --git a/src/hooks/useDispatch.js b/src/hooks/useDispatch.ts
similarity index 100%
rename from src/hooks/useDispatch.js
rename to src/hooks/useDispatch.ts
diff --git a/src/hooks/useReduxContext.js b/src/hooks/useReduxContext.ts
similarity index 100%
rename from src/hooks/useReduxContext.js
rename to src/hooks/useReduxContext.ts
diff --git a/src/hooks/useStore.js b/src/hooks/useStore.ts
similarity index 96%
rename from src/hooks/useStore.js
rename to src/hooks/useStore.ts
index 0f0eb83bc..85fd238d8 100644
--- a/src/hooks/useStore.js
+++ b/src/hooks/useStore.ts
@@ -14,7 +14,7 @@ export function createStoreHook(context = ReactReduxContext) {
? useDefaultReduxContext
: () => useContext(context)
return function useStore() {
- const { store } = useReduxContext()
+ const { store } = useReduxContext()!
return store
}
}
diff --git a/src/utils/batch.js b/src/utils/batch.ts
similarity index 65%
rename from src/utils/batch.js
rename to src/utils/batch.ts
index cf39ca940..134e635f9 100644
--- a/src/utils/batch.js
+++ b/src/utils/batch.ts
@@ -1,12 +1,12 @@
// Default to a dummy "batch" implementation that just runs the callback
-function defaultNoopBatch(callback) {
+function defaultNoopBatch(callback: () => void) {
callback()
}
let batch = defaultNoopBatch
// Allow injecting another batching function later
-export const setBatch = (newBatch) => (batch = newBatch)
+export const setBatch = (newBatch: (callback: () => void) => void) => (batch = newBatch)
// Supply a getter just to skip dealing with ESM bindings
export const getBatch = () => batch
diff --git a/src/utils/bindActionCreators.js b/src/utils/bindActionCreators.js
deleted file mode 100644
index 3e641d1c7..000000000
--- a/src/utils/bindActionCreators.js
+++ /dev/null
@@ -1,10 +0,0 @@
-export default function bindActionCreators(actionCreators, dispatch) {
- const boundActionCreators = {}
- for (const key in actionCreators) {
- const actionCreator = actionCreators[key]
- if (typeof actionCreator === 'function') {
- boundActionCreators[key] = (...args) => dispatch(actionCreator(...args))
- }
- }
- return boundActionCreators
-}
diff --git a/src/utils/bindActionCreators.ts b/src/utils/bindActionCreators.ts
new file mode 100644
index 000000000..d6d509809
--- /dev/null
+++ b/src/utils/bindActionCreators.ts
@@ -0,0 +1,25 @@
+import { ActionCreator, ActionCreatorsMapObject, AnyAction, Dispatch } from "redux"
+
+function bindActionCreator(
+ actionCreator: ActionCreator,
+ dispatch: Dispatch
+) {
+ return function (this: any, ...args: any[]) {
+ return dispatch(actionCreator.apply(this, args))
+ }
+}
+
+export default function bindActionCreators(actionCreators: ActionCreator | ActionCreatorsMapObject, dispatch: Dispatch) {
+ if (typeof actionCreators === 'function') {
+ return bindActionCreator(actionCreators, dispatch)
+ }
+
+ const boundActionCreators: ActionCreatorsMapObject = {}
+ for (const key in actionCreators) {
+ const actionCreator = actionCreators[key]
+ if (typeof actionCreator === 'function') {
+ boundActionCreators[key] = (...args) => dispatch(actionCreator(...args))
+ }
+ }
+ return boundActionCreators
+}
diff --git a/src/utils/isPlainObject.js b/src/utils/isPlainObject.ts
similarity index 88%
rename from src/utils/isPlainObject.js
rename to src/utils/isPlainObject.ts
index 3c2ee2faf..2157ea089 100644
--- a/src/utils/isPlainObject.js
+++ b/src/utils/isPlainObject.ts
@@ -2,7 +2,7 @@
* @param {any} obj The object to inspect.
* @returns {boolean} True if the argument appears to be a plain object.
*/
-export default function isPlainObject(obj) {
+export default function isPlainObject(obj: unknown) {
if (typeof obj !== 'object' || obj === null) return false
let proto = Object.getPrototypeOf(obj)
diff --git a/src/utils/shallowEqual.js b/src/utils/shallowEqual.ts
similarity index 86%
rename from src/utils/shallowEqual.js
rename to src/utils/shallowEqual.ts
index a2cbe04a3..e50c6be52 100644
--- a/src/utils/shallowEqual.js
+++ b/src/utils/shallowEqual.ts
@@ -1,4 +1,4 @@
-function is(x, y) {
+function is(x: unknown, y: unknown) {
if (x === y) {
return x !== 0 || y !== 0 || 1 / x === 1 / y
} else {
@@ -6,7 +6,7 @@ function is(x, y) {
}
}
-export default function shallowEqual(objA, objB) {
+export default function shallowEqual(objA: any, objB: any) {
if (is(objA, objB)) return true
if (
diff --git a/src/utils/useIsomorphicLayoutEffect.native.js b/src/utils/useIsomorphicLayoutEffect.native.ts
similarity index 100%
rename from src/utils/useIsomorphicLayoutEffect.native.js
rename to src/utils/useIsomorphicLayoutEffect.native.ts
diff --git a/src/utils/useIsomorphicLayoutEffect.js b/src/utils/useIsomorphicLayoutEffect.ts
similarity index 100%
rename from src/utils/useIsomorphicLayoutEffect.js
rename to src/utils/useIsomorphicLayoutEffect.ts
diff --git a/src/utils/verifyPlainObject.js b/src/utils/verifyPlainObject.ts
similarity index 69%
rename from src/utils/verifyPlainObject.js
rename to src/utils/verifyPlainObject.ts
index 8e98b39c2..2a8823dc9 100644
--- a/src/utils/verifyPlainObject.js
+++ b/src/utils/verifyPlainObject.ts
@@ -1,7 +1,7 @@
import isPlainObject from './isPlainObject'
import warning from './warning'
-export default function verifyPlainObject(value, displayName, methodName) {
+export default function verifyPlainObject(value: unknown, displayName: string, methodName: string) {
if (!isPlainObject(value)) {
warning(
`${methodName}() in ${displayName} must return a plain object. Instead received ${value}.`
diff --git a/src/utils/warning.js b/src/utils/warning.ts
similarity index 92%
rename from src/utils/warning.js
rename to src/utils/warning.ts
index 0fdfb0257..92d3d638b 100644
--- a/src/utils/warning.js
+++ b/src/utils/warning.ts
@@ -4,7 +4,7 @@
* @param {String} message The warning message.
* @returns {void}
*/
-export default function warning(message) {
+export default function warning(message: string) {
/* eslint-disable no-console */
if (typeof console !== 'undefined' && typeof console.error === 'function') {
console.error(message)