Skip to content

Instantly share code, notes, and snippets.



Last active Apr 27, 2019
What would you like to do?
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
You can’t perform that action at this time.