In order to create a type from another type in TypeScript, used the Pick mapped type which will construct a type based on a subset of properties of another type as follows:-
interface IHomeAppliance { table : string; bed : string; bathroom : string; } type PickBathroom = Pick<IHomeAppliance, "bathroom"> let pick_bathroom : PickBathroom = { bathroom : "bathtub" } console.log("I like to take bath inside " + pick_bathroom.bathroom)
As you all can see Pick allows us to pick properties that require us to create our type from the original type! The above program will produce the following outcome:-
I like to take bath inside bathtub