@mintlify/common
Version:
Commonly shared code within Mintlify
11 lines (10 loc) • 688 B
TypeScript
/**
* Reads `obj[key]` when `key` is only known at runtime.
*
* Navigation config types such as `DecoratedNavigationConfig` are large discriminated unions
* (`{ languages: … } | { versions: … } | …`). TypeScript cannot type `obj[key]` for `key: string`
* without collapsing the union. Call sites pass validated config from Zod; we narrow with
* `Array.isArray` and `typeof item === 'object'`, then assert each element to `T` once.
*/
export declare function readObjectArrayProperty<T extends object>(obj: object, key: string): T[] | undefined;
export declare function iterateObjectArrayProperty<T extends object>(obj: object, key: string, visit: (element: T) => void): void;