Skip to content
On this page

2023년 06월 22일

수정하기
문서 생성 2023-06-22 14:42:12 최근 수정 2023-06-22 14:42:26
미라클 모닝

📚 오늘 도전하고, 배운 것

TypeScript에서 중첩 객체 property에 Partial을 적용하는 방법

type NestedPartial<T> = {
[K in keyof T]?: T[K] extends Array<infer R> ? Array<NestedPartial<R>> : NestedPartial<T[K]>
};

https://stackoverflow.com/questions/47914536/use-partial-in-nested-property-with-typescript

Redux Toolkit with TypeScript

// src/store/index.ts
const store = configureStore({
reducer: {
movies: moviesReducer,
books: booksReducer
}
})
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;
// src/store/slices/moviesSlice.ts
const initialState: {
name: string;
cost: number;
} = {
name: "",
cost: 0,
}
const moviesSlice = createSlice({
name: "movie",
initialState,
reducers: {
changeName(state, action: PayloadAction<string>) {
state.name = action.payload
},
changeCost(state, action: PayloadAction<number>) {
state.cost = action.payload
}
}
})
export const { changeName, changeCost } = moviesSlice.actions
export const moviesReducer = moviesSlice.reducer

🤔 학습하면서 궁금하거나 어려웠던 점

🌅 내일은 무엇을?

  • frontend 인증 구현

✒️ log

  • 모기 때문에 강제 미라클 모닝을 했다.

LINKS TO THIS PAGE