// Type
type UserType = {
name: string;
email: string;
};
// Object
const user: UserType = {
name: "Bob",
email: "bob@bob.com"
};
// Get Object property by name
const name = user["name" as keyof UserType] // name = "Bob"
// Alternatively, create object property type
type ObjectKey = keyof typeof user; // type ObjectKey = "name" | "email"
const myKey = "name" as ObjectKey;
const name = user[myKey]; // name = "Bob"