Skip to content

Commit 88692ae

Browse files
authored
Merge pull request #1726 from reduxjs/pr/remove-typeof
2 parents dc673a3 + 3bd595b commit 88692ae

File tree

5 files changed

+7
-13
lines changed

5 files changed

+7
-13
lines changed

packages/toolkit/src/createReducer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export function createReducer<S extends NotFunction<any>>(
253253
const draft = previousState as Draft<S> // We can assume this is already a draft
254254
const result = caseReducer(draft, action)
255255

256-
if (typeof result === 'undefined') {
256+
if (result === undefined) {
257257
return previousState
258258
}
259259

@@ -263,7 +263,7 @@ export function createReducer<S extends NotFunction<any>>(
263263
// return the caseReducer func and not wrap it with produce.
264264
const result = caseReducer(previousState as any, action)
265265

266-
if (typeof result === 'undefined') {
266+
if (result === undefined) {
267267
if (previousState === null) {
268268
return previousState
269269
}

packages/toolkit/src/immutableStateInvariantMiddleware.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,7 @@ function getSerialize(
6767
* @public
6868
*/
6969
export function isImmutableDefault(value: unknown): boolean {
70-
return (
71-
typeof value !== 'object' ||
72-
value === null ||
73-
typeof value === 'undefined' ||
74-
Object.isFrozen(value)
75-
)
70+
return typeof value !== 'object' || value == null || Object.isFrozen(value)
7671
}
7772

7873
export function trackForMutations(

packages/toolkit/src/query/fetchBaseQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function stripUndefined(obj: any) {
104104
}
105105
const copy: Record<string, any> = { ...obj }
106106
for (const [k, v] of Object.entries(copy)) {
107-
if (typeof v === 'undefined') delete copy[k]
107+
if (v === undefined) delete copy[k]
108108
}
109109
return copy
110110
}

packages/toolkit/src/query/react/buildHooks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ import type { BaseQueryFn } from '../baseQueryTypes'
5858
// Copy-pasted from React-Redux
5959
export const useIsomorphicLayoutEffect =
6060
typeof window !== 'undefined' &&
61-
typeof window.document !== 'undefined' &&
62-
typeof window.document.createElement !== 'undefined'
61+
window.document &&
62+
window.document.createElement
6363
? useLayoutEffect
6464
: useEffect
6565

packages/toolkit/src/serializableStateInvariantMiddleware.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import { getTimeMeasureUtils } from './utils'
1414
export function isPlain(val: any) {
1515
const type = typeof val
1616
return (
17-
type === 'undefined' ||
18-
val === null ||
17+
val == null ||
1918
type === 'string' ||
2019
type === 'boolean' ||
2120
type === 'number' ||

0 commit comments

Comments
 (0)