타입스크립트 문법 처리

declare namespace Immutable {
  type DeepImmutable<T> =
    T extends (infer R)[] ? DeepImmutableList<R> :
    T extends object ? DeepImmutableMap<T> :
    T;

  interface DeepImmutableMap<T> {
    get<K extends keyof T>(key: K): DeepImmutable<T[K]>;
  }

  interface DeepImmutableList<T> {
    get(idx: number): DeepImmutable<T>;
  }

  export function fromJS<T>(source: T): DeepImmutable<T>;
  export function toJS<T>(obj: DeepImmutable<T>): T;
}