Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8ba64bc

Browse files
authored
explicitly castinitialState in docs examples (#827)
1 parent12ed030 commit8ba64bc

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

‎docs/api/createAsyncThunk.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,10 @@ interface UsersState {
574574
entities:Record<string,User>
575575
}
576576

577-
const initialState:UsersState= {
577+
const initialState= {
578578
entities: {},
579579
error:null
580-
}
580+
}asUsersState
581581

582582
const usersSlice=createSlice({
583583
name:'users',

‎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:CounterState= { value:0 }
55+
const initialState= { value:0 }asCounterState
5656

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

‎docs/api/createSlice.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface CounterState {
2222
value:number
2323
}
2424

25-
const initialState:CounterState= { value:0 }
25+
const initialState= { value:0 }asCounterState
2626

2727
const counterSlice=createSlice({
2828
name:'counter',

‎docs/api/matching-utilities.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ interface ExampleState {
174174
isInteresting:boolean
175175
}
176176

177-
const initialState:ExampleState= {
177+
const initialState= {
178178
isSpecial:false,
179179
isInteresting:false
180-
}
180+
}asExampleState
181181

182182
exportconst isSpecialAndInterestingThunk=createAsyncThunk(
183183
'isSpecialAndInterestingThunk',

‎docs/api/otherExports.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ interface Todo {
3838
}
3939
const addTodo=createAction<Todo>('addTodo')
4040

41-
const initialState:Todo[]=[]
41+
const initialState=[]asTodo[]
4242

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

‎docs/tutorials/advanced-tutorial.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ type CurrentDisplayState = {
204204
}&CurrentDisplay&
205205
CurrentRepo
206206

207-
let initialState:CurrentDisplayState= {
207+
let initialState= {
208208
org:'rails',
209209
repo:'rails',
210210
page:1,
211211
displayType:'issues',
212212
issueId:null
213-
}
213+
}asCurrentDisplayState
214214

215215
const issuesDisplaySlice=createSlice({
216216
name:'issuesDisplay',
@@ -575,10 +575,10 @@ interface RepoDetailsState {
575575
error:string|null
576576
}
577577

578-
const initialState:RepoDetailsState= {
578+
const initialState= {
579579
openIssuesCount:-1,
580580
error:null
581-
}
581+
}asRepoDetailsState
582582

583583
const repoDetails=createSlice({
584584
name:'repoDetails',
@@ -761,14 +761,14 @@ interface IssuesState {
761761
error:string|null
762762
}
763763

764-
const issuesInitialState:IssuesState= {
764+
const issuesInitialState= {
765765
issuesByNumber: {},
766766
currentPageIssues: [],
767767
pageCount:0,
768768
pageLinks: {},
769769
isLoading:false,
770770
error:null
771-
}
771+
}asIssuesState
772772

773773
function startLoading(state:IssuesState) {
774774
state.isLoading=true
@@ -1082,11 +1082,11 @@ interface CommentLoaded {
10821082
comments:Comment[]
10831083
}
10841084

1085-
const initialState:CommentsState= {
1085+
const initialState= {
10861086
commentsByIssue: {},
10871087
loading:false,
10881088
error:null
1089-
}
1089+
}asCommentsState
10901090

10911091
const comments=createSlice({
10921092
name:'comments',

‎docs/usage/usage-with-typescript.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ The standard approach is to declare an interface or type for your state, create
277277
typeSliceState= { state:'loading' }| { state:'finished'; data:string }
278278

279279
// First approach: define the initial state using that type
280-
const initialState:SliceState= { state:'loading' }
280+
const initialState= { state:'loading' }:SliceState
281281

282282
createSlice({
283283
name:'test1',
@@ -367,10 +367,10 @@ interface UsersState {
367367
loading:'idle'|'pending'|'succeeded'|'failed'
368368
}
369369

370-
const initialState:UsersState= {
370+
const initialState= {
371371
entities: [],
372372
loading:'idle'
373-
}
373+
}asUsersState
374374

375375
const usersSlice=createSlice({
376376
name:'users',

‎docs/virtual/matchers/index.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ export interface ExampleState {
3434
isInteresting:boolean
3535
}
3636

37-
exportconstinitialState:ExampleState={
37+
exportconstinitialState={
3838
isSpecial:false,
3939
isInteresting:false
40-
}
40+
}asExampleState
4141

4242
exportconstisSpecialAndInterestingThunk=createAsyncThunk(
4343
'isSpecialAndInterestingThunk',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp