Created
July 13, 2019 05:34
-
-
Save xiaoxiangmoe/b3882aa798f03cb9924d293cf74514be to your computer and use it in GitHub Desktop.
DeepReadonly
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
// tslint:disable | |
interface DeepReadonlyArray<T> extends ReadonlyArray<DeepReadonly<T>> {} | |
type DeepReadonlyObject<T> = T extends Function | |
? T | |
: { readonly [P in keyof T]: DeepReadonly<T[P]> }; | |
export type DeepReadonly<T> = T extends any[] | |
? DeepReadonlyArray<T[number]> | |
: T extends object | |
? DeepReadonlyObject<T> | |
: T; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment