/**
 * NonUndefined
 * @desc Exclude undefined from set `A`
 * @example
 *   // Expect: "string | null"
 *   NonUndefined<string | null | undefined>;
 */
export type NonUndefined<A> = A extends undefined ? never : A;

/**
 * StringKeys
 * @desc Get union type of keys that are string in object type `T`
 * @example
 *   type MixedProps = {name: string; surname: title; phone: number; postalCode: number};
 *
 *   // Expect: "name | surname"
 *   type Keys = StringKeys<MixedProps>;
 */
export type StringKeys<T extends object> = {
  [K in keyof T]-?: NonUndefined<T[K]> extends string ? K : never;
}[keyof T];
