/** * Generic для определения опциональности параметра. * @example * ```typescript * type ExampleFunction = (requiredParam: string, optionalParam?: string) => void; * * type IsFirstParamOptional = IsOptionalParam[0]>; // false * type IsSecondParamOptional = IsOptionalParam[1]>; // true * ``` */ export type IsOptionalParam = undefined extends T ? true : false; /** * Generic для определения опциональных ключей объекта. * @example * ```typescript * type ExampleObject = { id: string; page?: number }; * type OptionalKeys = OptionalKeys; // 'page' * ``` */ export type OptionalKeys> = keyof { [TKey in keyof TObject as undefined extends TObject[TKey] ? TKey : never]: TObject[TKey]; };