Skip to content

Commit d001ac3

Browse files
committed
Merge branch 'master' of https://github.com/reduxjs/redux-toolkit into configs
2 parents e1f40e2 + 4b9977e commit d001ac3

21 files changed

+10558
-11021
lines changed

.codesandbox/ci.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"/examples/action-listener/counter",
99
"/examples/publish-ci/cra5"
1010
],
11-
"node": "16",
11+
"node": "18",
1212
"buildCommand": "build:packages",
1313
"packages": [
1414
"packages/toolkit",

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- uses: actions/checkout@v3
2929
- uses: actions/setup-node@v3
3030
with:
31-
node-version: '18.x'
31+
node-version: '20.x'
3232
registry-url: 'https://registry.npmjs.org'
3333
cache: 'yarn'
3434
- run: yarn install --frozen-lockfile

.github/workflows/test-codegen.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131

3232
strategy:
3333
matrix:
34-
node-version: ['18.x']
34+
node-version: ['20.x']
3535

3636
steps:
3737
- uses: actions/checkout@v2

.github/workflows/tests.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
runs-on: ubuntu-latest
3131
strategy:
3232
matrix:
33-
node: ['18.x']
33+
node: ['20.x']
3434

3535
steps:
3636
- name: Checkout repo
@@ -67,7 +67,7 @@ jobs:
6767
strategy:
6868
fail-fast: false
6969
matrix:
70-
node: ['18.x']
70+
node: ['20.x']
7171
steps:
7272
- name: Checkout repo
7373
uses: actions/checkout@v2
@@ -104,7 +104,7 @@ jobs:
104104
strategy:
105105
fail-fast: false
106106
matrix:
107-
node: ['18.x']
107+
node: ['20.x']
108108
ts: ['4.7', '4.8', '4.9', '5.0', '5.1', '5.2', '5.3']
109109
steps:
110110
- name: Checkout repo
@@ -148,7 +148,7 @@ jobs:
148148
strategy:
149149
fail-fast: false
150150
matrix:
151-
node: ['18.x']
151+
node: ['20.x']
152152
example:
153153
[
154154
'cra4',
@@ -163,6 +163,8 @@ jobs:
163163
defaults:
164164
run:
165165
working-directory: ./examples/publish-ci/${{ matrix.example }}
166+
env:
167+
YARN_ENABLE_IMMUTABLE_INSTALLS: "false"
166168
steps:
167169
- name: Checkout repo
168170
uses: actions/checkout@v2
@@ -214,7 +216,7 @@ jobs:
214216
strategy:
215217
fail-fast: false
216218
matrix:
217-
node: ['18.x']
219+
node: ['20.x']
218220
steps:
219221
- name: Checkout repo
220222
uses: actions/checkout@v2

.yarn/plugins/@yarnpkg/plugin-version.cjs

-550
This file was deleted.

.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

-28
This file was deleted.

.yarn/releases/yarn-3.2.4.cjs

-801
This file was deleted.

.yarn/releases/yarn-4.1.0.cjs

+893
Large diffs are not rendered by default.

.yarnrc.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
nodeLinker: node-modules
1+
compressionLevel: mixed
2+
3+
enableGlobalCache: false
24

3-
plugins:
4-
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
5-
spec: '@yarnpkg/plugin-workspace-tools'
6-
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
7-
spec: '@yarnpkg/plugin-version'
5+
nodeLinker: node-modules
86

9-
yarnPath: .yarn/releases/yarn-3.2.4.cjs
7+
yarnPath: .yarn/releases/yarn-4.1.0.cjs

docs/api/autoBatchEnhancer.mdx

+1-1
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/createAsyncThunk.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ const fetchUserById = createAsyncThunk(
3939
)
4040

4141
interface UsersState {
42-
entities: []
42+
entities: User[]
4343
loading: 'idle' | 'pending' | 'succeeded' | 'failed'
4444
}
4545

4646
const initialState = {
4747
entities: [],
4848
loading: 'idle',
49-
} as UsersState
49+
} satisfies UserState as UsersState
5050

5151
// Then, handle actions in your reducers:
5252
const usersSlice = createSlice({
@@ -699,7 +699,7 @@ interface UsersState {
699699
const initialState = {
700700
entities: {},
701701
error: null,
702-
} as UsersState
702+
} satisfies UsersState as UsersState
703703

704704
const usersSlice = createSlice({
705705
name: 'users',

docs/api/createReducer.mdx

+1-1
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

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface CounterState {
2525
value: number
2626
}
2727

28-
const initialState = { value: 0 } as CounterState
28+
const initialState = { value: 0 } satisfies CounterState as CounterState
2929

3030
const counterSlice = createSlice({
3131
name: 'counter',
@@ -158,7 +158,7 @@ const todosSlice = createSlice({
158158
initialState: {
159159
loading: false,
160160
todos: [],
161-
} as TodoState,
161+
} satisfies TodoState as TodoState,
162162
reducers: (create) => ({
163163
deleteTodo: create.reducer<number>((state, action) => {
164164
state.todos.splice(action.payload, 1)
@@ -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
},
@@ -608,7 +608,7 @@ const decrementBy = createAction<number>('decrementBy')
608608

609609
const counter = createSlice({
610610
name: 'counter',
611-
initialState: 0 as number,
611+
initialState: 0 satisfies number as number,
612612
reducers: {
613613
increment: (state) => state + 1,
614614
decrement: (state) => state - 1,

docs/api/matching-utilities.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ interface ExampleState {
181181
const initialState = {
182182
isSpecial: false,
183183
isInteresting: false,
184-
} as ExampleState
184+
} satisfies ExampleState as ExampleState
185185

186186
export const isSpecialAndInterestingThunk = createAsyncThunk(
187187
'isSpecialAndInterestingThunk',

docs/api/otherExports.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ interface Todo {
6666
}
6767
const addTodo = createAction<Todo>('addTodo')
6868

69-
const initialState = [] as Todo[]
69+
const initialState = [] satisfies Todo[] as Todo[]
7070

7171
const todosReducer = createReducer(initialState, (builder) => {
7272
builder.addCase(addTodo, (state, action) => {

docs/tutorials/typescript.md

+1-1
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

docs/usage/usage-with-typescript.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ createSlice({
273273

274274
You might have noticed that it is not a good idea to pass your `SliceState` type as a generic to `createSlice`. This is due to the fact that in almost all cases, follow-up generic parameters to `createSlice` need to be inferred, and TypeScript cannot mix explicit declaration and inference of generic types within the same "generic block".
275275

276-
The standard approach is to declare an interface or type for your state, create an initial state value that uses that type, and pass the initial state value to `createSlice`. You can also use the construct `initialState: myInitialState as SliceState`.
276+
The standard approach is to declare an interface or type for your state, create an initial state value that uses that type, and pass the initial state value to `createSlice`. You can also use the construct `initialState: myInitialState satisfies SliceState as SliceState`.
277277

278278
```ts {1,4,8,15}
279279
type SliceState = { state: 'loading' } | { state: 'finished'; data: string }
@@ -290,7 +290,7 @@ createSlice({
290290
// Or, cast the initial state as necessary
291291
createSlice({
292292
name: 'test2',
293-
initialState: { state: 'loading' } as SliceState,
293+
initialState: { state: 'loading' } satisfies SliceState as SliceState,
294294
reducers: {},
295295
})
296296
```
@@ -368,14 +368,14 @@ const fetchUserById = createAsyncThunk(
368368
)
369369

370370
interface UsersState {
371-
entities: []
371+
entities: User[]
372372
loading: 'idle' | 'pending' | 'succeeded' | 'failed'
373373
}
374374

375375
const initialState = {
376376
entities: [],
377377
loading: 'idle',
378-
} as UsersState
378+
} satisfies UsersState as UsersState
379379

380380
const usersSlice = createSlice({
381381
name: 'users',

docs/virtual/matchers/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface ExampleState {
3737
export const initialState = {
3838
isSpecial: false,
3939
isInteresting: false,
40-
} as ExampleState
40+
} satisfies ExampleState as ExampleState
4141

4242
export const isSpecialAndInterestingThunk = createAsyncThunk(
4343
'isSpecialAndInterestingThunk',

netlify.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
ignore = "git diff --quiet HEAD^ HEAD docs website"
66

77
[build.environment]
8-
NODE_VERSION = "16"
8+
NODE_VERSION = "20"
99
NODE_OPTIONS = "--max_old_space_size=4096"
1010
NETLIFY_USE_YARN = "true"
1111
YARN_VERSION = "1.22.10"

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@
7676
"scripts": {
7777
"build": "yarn build:packages",
7878
"test": "yarn test:packages",
79-
"build:configs": "yarn workspaces foreach --include '@reduxjs/*config' -vtp run build",
80-
"build:examples": "yarn workspaces foreach --include '@reduxjs/*' --include '@examples-query-react/*' --include '@examples-action-listener/*' -vtp run build",
79+
"build:configs": "yarn workspaces foreach -A --include '@reduxjs/*config' -vtp run build",
80+
"build:examples": "yarn workspaces foreach -A --include '@reduxjs/*' --include '@examples-query-react/*' --include '@examples-action-listener/*' -vtp run build",
8181
"build:docs": "yarn workspace website run build",
82-
"build:packages": "yarn workspaces foreach --include '@reduxjs/*' --include '@rtk-query/*' --topological-dev run build",
83-
"test:packages": "yarn workspaces foreach --include '@reduxjs/*' --include '@rtk-query/*' --include '@rtk-incubator/*' run test",
82+
"build:packages": "yarn workspaces foreach -A --include '@reduxjs/*' --include '@rtk-query/*' --topological-dev run build",
83+
"test:packages": "yarn workspaces foreach -A --include '@reduxjs/*' --include '@rtk-query/*' --include '@rtk-incubator/*' run test",
8484
"dev:docs": "yarn workspace website run start"
85-
}
85+
},
86+
"packageManager": "yarn@4.1.0"
8687
}

0 commit comments

Comments
 (0)