Skip to content

Commit 18a6b2a

Browse files
committed
Cut excessive assertions in createAction.test-d.tsx
1 parent bf6bd48 commit 18a6b2a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

packages/toolkit/src/tests/createAction.test-d.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ describe('type tests', () => {
7878
}),
7979
{ type: 'action' },
8080
) as PayloadActionCreator
81-
const actionCreator: ActionCreator<UnknownAction> = payloadActionCreator
81+
82+
expectTypeOf(payloadActionCreator).toMatchTypeOf<
83+
ActionCreator<UnknownAction>
84+
>()
8285

8386
const payloadActionCreator2 = Object.assign(
8487
(payload?: number) => ({
@@ -88,8 +91,9 @@ describe('type tests', () => {
8891
{ type: 'action' },
8992
) as PayloadActionCreator<number>
9093

91-
const actionCreator2: ActionCreator<PayloadAction<number>> =
92-
payloadActionCreator2
94+
expectTypeOf(payloadActionCreator2).toMatchTypeOf<
95+
ActionCreator<PayloadAction<number>>
96+
>()
9397
})
9498
})
9599

@@ -104,6 +108,7 @@ describe('type tests', () => {
104108

105109
test('createAction() type parameter is required, not inferred (defaults to `void`).', () => {
106110
const increment = createAction('increment')
111+
107112
expectTypeOf(increment).parameter(0).not.toBeNumber()
108113

109114
expectTypeOf(increment().payload).not.toBeNumber()
@@ -279,10 +284,6 @@ describe('type tests', () => {
279284
expectTypeOf(x.filter(actionCreator.match)).toEqualTypeOf<
280285
PayloadAction<string, 'test'>[]
281286
>()
282-
283-
expectTypeOf(x.filter(actionCreator.match)).not.toEqualTypeOf<
284-
PayloadAction<number, 'test'>[]
285-
>()
286287
})
287288
})
288289
})
@@ -319,6 +320,7 @@ describe('type tests', () => {
319320

320321
test("Verify action creators should not be passed directly as arguments to React event handlers if there shouldn't be a payload", () => {
321322
const emptyAction = createAction<void>('empty/action')
323+
322324
function TestComponent() {
323325
// This typically leads to an error like:
324326
// // A non-serializable value was detected in an action, in the path: `payload`.

0 commit comments

Comments
 (0)