mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 15:36:25 +00:00
5109f9b794
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jamie Magee <jamie.magee@gmail.com>
13 lines
382 B
TypeScript
13 lines
382 B
TypeScript
/**
|
|
* This is a workaround helper to allow the usage of 'unknown' in
|
|
* a type-guard function while checking that keys exist.
|
|
*
|
|
* @see https://github.com/microsoft/TypeScript/issues/21732
|
|
* @see https://stackoverflow.com/a/58630274
|
|
*/
|
|
export function hasKey<K extends string, T>(
|
|
k: K,
|
|
o: T
|
|
): o is T & Record<K, unknown> {
|
|
return o && typeof o === 'object' && k in o;
|
|
}
|