Skip to content

Commit fee953e

Browse files
committed
Fix @typescript-eslint/no-unused-expressions related issues
1 parent 89fc8f9 commit fee953e

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

packages/toolkit/src/immutableStateInvariantMiddleware.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Middleware } from 'redux'
22
import type { IgnorePaths } from './serializableStateInvariantMiddleware'
3+
import type { AnyObject } from './tsHelpers'
34
import { getTimeMeasureUtils } from './utils'
45

56
type EntryProcessor = (key: string, value: any) => any
@@ -190,8 +191,16 @@ export function createImmutableStateInvariantMiddleware(
190191
return function (this: any, key: string, value: any) {
191192
if (stack.length > 0) {
192193
const thisPos = stack.indexOf(this)
193-
~thisPos ? stack.splice(thisPos + 1) : stack.push(this)
194-
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key)
194+
if (~thisPos) {
195+
stack.splice(thisPos + 1)
196+
} else {
197+
stack.push(this)
198+
}
199+
if (~thisPos) {
200+
keys.splice(thisPos, Infinity, key)
201+
} else {
202+
keys.push(key)
203+
}
195204
if (~stack.indexOf(value)) value = decycler!.call(this, key, value)
196205
} else stack.push(value)
197206

packages/toolkit/src/query/core/buildMiddleware/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ import type {
2626
} from './types'
2727
import { buildWindowEventHandler } from './windowEventHandling'
2828

29+
export type { ReferenceCacheCollection } from './cacheCollection'
30+
export type {
31+
MutationCacheLifecycleApi,
32+
QueryCacheLifecycleApi,
33+
ReferenceCacheLifecycle,
34+
} from './cacheLifecycle'
35+
export type {
36+
MutationLifecycleApi,
37+
QueryLifecycleApi,
38+
ReferenceQueryLifecycle,
39+
} from './queryLifecycle'
40+
export type { SubscriptionSelectors } from './types'
41+
2942
export function buildMiddleware<
3043
Definitions extends EndpointDefinitions,
3144
ReducerPath extends string,

packages/toolkit/src/query/tests/cacheCollection.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ test(`query: handles large keepUnuseDataFor values over 32-bit ms`, async () =>
8787
expect(onCleanup).not.toHaveBeenCalled()
8888

8989
// _Should_ be called _wayyyy_ in the future (like 24.8 days from now)
90-
vi.advanceTimersByTime(THIRTY_TWO_BIT_MAX_TIMER_SECONDS * 1000),
91-
expect(onCleanup).toHaveBeenCalled()
90+
vi.advanceTimersByTime(THIRTY_TWO_BIT_MAX_TIMER_SECONDS * 1000)
91+
expect(onCleanup).toHaveBeenCalled()
9292
})
9393

9494
describe(`query: await cleanup, keepUnusedDataFor set`, () => {

packages/toolkit/src/tests/createAsyncThunk.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,8 +996,7 @@ describe('meta', () => {
996996
/* empty */
997997
} else {
998998
// could be caused by a `throw`, `abort()` or `condition` - no `rejectedMeta` in that case
999-
// @ts-expect-error
1000-
ret.meta.extraProp
999+
expect(ret.meta).not.toHaveProperty('extraProp')
10011000
}
10021001
})
10031002

packages/toolkit/src/tests/createDraftSafeSelector.withTypes.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ describe(createDraftSafeSelector.withTypes, () => {
4444
(todos) => todos.map(({ id }) => id),
4545
)
4646

47-
expect(selectTodoIds(rootState)).to.be.an('array').that.is.not.empty
47+
expect(selectTodoIds(rootState)).to.be.an('array').with.lengthOf(2)
4848
})
4949
})

0 commit comments

Comments
 (0)