Sorry if the question sounds vague, basically;
I have a struct
type User = {
name: string,
age: number,
}
I specifically want to map the attributes into an array by doing
type UserKey = Array<keyof User>;
Later in the code, I want to map the variables which has UserKey type into something else, say into table headers
let tableHeaders: UserKey = ["name", "age"];
Everything is working as expected, but I want the array to have every key from the User so nothing is left out if the case maybe I add another attribute to User type in the future, the code will show error because not all key is covered in the array
let tableHeaders: UserKey = ["name", "age", "gender"]; // this will error as expected
let tableHeaders: UserKey = ["name"]; // this will not error, but I want this to error instead
Expectation:
let tableHeaders: UserKey = ["name"]; // ERROR, age key is required