import { PartiallyReadOnly } from '../../types/partialy-readonly'; import { InferIterableValues } from '../infer/iterable'; export function FreezeObjectProperty(target: TObject, propertyKey: TKey): PartiallyReadOnly { const descriptor: PropertyDescriptor | undefined = Object.getOwnPropertyDescriptor(target, propertyKey); if (descriptor === void 0) { throw new Error(`Missing property ${ String(propertyKey) }`); } else { const value: any = target[propertyKey]; Object.defineProperty(target, propertyKey, { enumerable: descriptor.enumerable, configurable: false, get: () => value, }); } return target; } export function FreezeObjectProperties>( target: TObject, propertyKeys: TKeys ): PartiallyReadOnly> { const iterator: Iterator = propertyKeys[Symbol.iterator](); let result: IteratorResult; while (!(result = iterator.next()).done) { FreezeObjectProperty>(target, result.value); } return target; }