typedash
Version:
modern, type-safe collection of utility functions
25 lines (24 loc) • 1.03 kB
text/typescript
import { t as KeysOfUnion } from "./KeysOfUnion-D3-apcAx.cjs";
//#region src/types/StringWithAutocomplete.d.ts
/**
* A utility type around `string` that allows for autocomplete on the string on a specific set of values, yet accepting any string.
* @see https://twitter.com/diegohaz/status/1524257274012876801
*/
type StringWithAutocomplete<S extends string> = S | (string & Record<never, never>);
//#endregion
//#region src/functions/hasKey/hasKey.d.ts
/**
* Returns whether the input value has the specified key.
* @param value The value to check.
* @param key The key to check for.
* @returns Whether the input value has the specified key.
* @example
* ```ts
* hasKey({ a: 1 }, 'a') // true
* hasKey({ a: 1 }, 'b') // false
* ```
*/
declare function hasKey<T extends object, K extends StringWithAutocomplete<KeysOfUnion<T> & string> | PropertyKey>(value: T, key: K): value is T & Record<K, unknown>;
//#endregion
export { StringWithAutocomplete as n, hasKey as t };
//# sourceMappingURL=hasKey-BoYRueGA.d.cts.map