keyof
operator takes interface or type and returns literal or numerical union of keys, which can be used as a type.
type ExampleType = { name: string, age: number } type KeysOfExampleType = keyof ExampleType // "name" | "age" type TypeWithSameKeysAsExample = { [key in keyof ExampleType]: string } const obj: {value: KeysOfExampleType}: { value: "something" // Type 'something' is not assignable to type 'keyof ExampleType`` } const obj2: TypeWithSameKeysAsExample = {} // Type '{}' is missing the following properties from type 'TypeWithSameKeysAsExample': name, age