What I wanted to know is if it is possible to use an interface to describe the parameters that need to be passed to a function. An example would be the following:
interface Person {
name: string;
age: number;
}
function createPerson(name: string, age: number) {}
I'd like to use the Person interface as a reference for the createPerson parameters. So far, I've been using this:
function createPerson(name: Person['name'], age: Person['age']) {}
While it's better than nothing I still don't know if it is the best way for me to do this, since I still need to rewrite all parameter names. Is there a better option? Thanks in advance.
function createPerson(person: Person)(orfunction createPerson({name, age}: Person).