Skip to main content

KeysMatch (Type)

Type Aliases

KeysMatch

type KeysMatch<T, Keys> = [keyof T] extends [Keys[number]] ? [Keys[number]] extends [keyof T] ? true : object : object;

Defined in: types/KeysMatch.ts:16

Helper type to ensure that an array of keys matches an interface.

For example:

interface Foo {
arg1: string;
arg2: string;
}

const FOO_KEYS = ["arg1", "arg2"] as const;
type _ = Expect<KeysMatch<Foo, typeof FOO_KEYS>>;

Type Parameters

Type Parameter
T
Keys extends readonly PropertyKey[]