Is it possible to use a variable to get the typeof a key in a interface?
For example:
interface DbSchema {
jobs: {
jobId: number;
jobName: string;
}
users: {
userId: number;
userName: string;
}
}
// I know we can do this:
type JobsType = DbSchema["jobs"];
// Is there a way to do this:
const str = "jobs";
type JobsType = DbSchema[str];