Skip to content

Commit e9a9ad3

Browse files
committed
Fix createAction type tests per review
1 parent 6d3528a commit e9a9ad3

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

type-tests/files/createAction.typetest.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function expectType<T>(p: T): T {
1919
}
2020

2121
/*
22-
* Test: PayloadAction type parameter is optional (defaults to `any`).
22+
* Test: PayloadAction type parameter is required.
2323
*/
2424
{
2525
// typings:expect-error
@@ -61,12 +61,10 @@ function expectType<T>(p: T): T {
6161
payload
6262
}),
6363
{ type: 'action' }
64-
) as PayloadActionCreator<number>
64+
) as PayloadActionCreator<number | undefined>
6565

6666
expectType<PayloadAction<number>>(actionCreator(1))
67-
// typings:expect-error
6867
expectType<PayloadAction<undefined>>(actionCreator())
69-
// typings:expect-error
7068
expectType<PayloadAction<undefined>>(actionCreator(undefined))
7169

7270
// typings:expect-error
@@ -118,12 +116,9 @@ function expectType<T>(p: T): T {
118116
* Test: createAction() type parameter is required, not inferred (defaults to `void`).
119117
*/
120118
{
121-
const increment = createAction<number>('increment')
122-
const n: number = increment(1).payload
123-
// typings:expect-error
124-
const s: string = increment('1').payload
119+
const increment = createAction('increment')
125120
// typings:expect-error
126-
const t: string = increment(1).payload
121+
const n: number = increment(1).payload
127122
}
128123
/*
129124
* Test: createAction().type is a string literal.

0 commit comments

Comments
 (0)