collectype

collectype v0.11.0


collectype / types/utility / StringKeys

Type Alias: StringKeys<T>

StringKeys<T> = { [K in keyof T]: T[K] extends string ? K : never }[keyof T]

Defined in: types/utility.ts:114

Returns the union of keys in T whose value type is string (including optional properties).

Type Parameters

T

T

The object type to inspect.

Example

type A = { foo: string; bar?: string; baz: number };
  type Keys = StringKeys<A>; // "foo" | "bar"