Skip to content

Commit 88aea76

Browse files
committed
suggest using the satisfies operator for initialState
1 parent 9577c69 commit 88aea76

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

docs/api/autoBatchEnhancer.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface CounterState {
2727

2828
const counterSlice = createSlice({
2929
name: 'counter',
30-
initialState: { value: 0 } as CounterState,
30+
initialState: { value: 0 } satisfies CounterState as CounterState,
3131
reducers: {
3232
incrementBatched: {
3333
// Batched, low-priority

docs/api/createReducer.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const increment = createAction('counter/increment')
5252
const decrement = createAction('counter/decrement')
5353
const incrementByAmount = createAction<number>('counter/incrementByAmount')
5454

55-
const initialState = { value: 0 } as CounterState
55+
const initialState = { value: 0 } satisfies CounterState as CounterState
5656

5757
const counterReducer = createReducer(initialState, (builder) => {
5858
builder

docs/api/createSlice.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ interface CounterState {
513513

514514
const counterSlice = createSlice({
515515
name: 'counter',
516-
initialState: { value: 0 } as CounterState,
516+
initialState: { value: 0 } satisfies CounterState as CounterState,
517517
reducers: {
518518
// omitted
519519
},
@@ -542,7 +542,7 @@ interface CounterState {
542542

543543
const counterSlice = createSlice({
544544
name: 'counter',
545-
initialState: { value: 0 } as CounterState,
545+
initialState: { value: 0 } satisfies CounterState as CounterState,
546546
reducers: {
547547
// omitted
548548
},

docs/tutorials/typescript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ In some cases, [TypeScript may unnecessarily tighten the type of the initial sta
149149
// Workaround: cast state instead of declaring variable type
150150
const initialState = {
151151
value: 0,
152-
} as CounterState
152+
} satisfies CounterState as CounterState
153153
```
154154

155155
### Use Typed Hooks in Components

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23604,11 +23604,11 @@ __metadata:
2360423604
linkType: hard
2360523605

2360623606
"prettier@npm:^2.1.1":
23607-
version: 2.3.1
23608-
resolution: "prettier@npm:2.3.1"
23607+
version: 2.8.8
23608+
resolution: "prettier@npm:2.8.8"
2360923609
bin:
2361023610
prettier: bin-prettier.js
23611-
checksum: 3b37731ff7150feecf19736c77c790e7e276b404ac9af81cbaf87cfecefc48ef9a864f34c2a5caf5955378b8f2525984b8611703a0d9c1f052b4cfa6eb35899f
23611+
checksum: b49e409431bf129dd89238d64299ba80717b57ff5a6d1c1a8b1a28b590d998a34e083fa13573bc732bb8d2305becb4c9a4407f8486c81fa7d55100eb08263cf8
2361223612
languageName: node
2361323613
linkType: hard
2361423614

0 commit comments

Comments
 (0)