Skip to content

KeysMatch (Type)

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 Parameter
T
Keys extends readonly PropertyKey[]