The title seems complicated. Let me dive into the subject matter. Take a look at an example:
export interface IUser {
id: string;
displayName: string;
email?: string;
imageUrl?: string;
disabled?: boolean;
since?: Date;
}
In a section of the code, I need to define a new variable - id
.
I want this variable's type to automatically match the type of IUser
's id
. So if IUser
is updated, the variable type updates dynamically like so:
let id:typeOf(IUser.id)