Last active
April 27, 2019 11:50
-
-
Save imkrish/6c942508c57e5a04e6df1be288424ccd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type DeepReadonlyObject<T> = { readonly [K in keyof T]: DeepReadonly<T[K]> }; | |
type DeepReadonly<T> = T extends (infer E)[][] | |
? ReadonlyArray<ReadonlyArray<DeepReadonlyObject<E>>> | |
: T extends (infer E)[] | |
? ReadonlyArray<DeepReadonlyObject<E>> | |
: T extends object | |
? DeepReadonlyObject<T> | |
: T; | |
interface ITodo { | |
task: string; | |
done: boolean; | |
} | |
interface IRootState { | |
userId: string; | |
showCompletedOnly: boolean; | |
todoTypes: string[]; | |
todos: ITodo[]; | |
iconGrid: string[][]; | |
} | |
type ReadonlyRootState = DeepReadonly<IRootState>; | |
let rootState: ReadonlyRootState; // Typescript service will prevent this variable from mutation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment