When working with Angular, I have been using TypeScript for some time now. Previously, I used to set function parameter types in a hardcoded way, as shown below:
login(email: string) {}
However, I recently tried to inherit from another object and changed my approach like this:
import { User } from './user.model';
login(email: User['email']) {}
Everything seems to be functioning properly, but I couldn't find any examples similar to this in the TypeScript cookbook. I am unsure if setting the type like this is the recommended practice. Can anyone provide guidance on whether or not it's appropriate to use the above construction according to TypeScript guidelines?