한번 감싸기
// asis
const toast = useSelector((state: MyState) => state.common.toast)
// tobe
export default function useTypedSelector<R>(selector: (state: MyState) => R): R {
return useSelector(selector)
}
타입 치환
interface DefaultMyState {
common: {...}
}
declare module 'react-redux' {
interface DefaultRootState extends DefaultMyState {}
}
'IT > typescript' 카테고리의 다른 글
[Typescript] Branded type (0) | 2024.02.21 |
---|---|
[Typescript] asserts를 이용한 타입 가드 활용 (0) | 2024.02.05 |
[Typescript] index signature vs mapped type (0) | 2024.02.05 |
[Typescript] enum vs union (0) | 2024.02.05 |
TS - 5.0 New features (0) | 2023.07.01 |