DEV Community

Yasunori Tanaka
Yasunori Tanaka

Posted on

Derive type info from a function

We can derive type from a function like this.

const createPerson = () => ({
  firstName: 'Yasunori',
  lastName: 'Tanaka',
})

type Person = ReturnType<typeof createPerson>

And then, use that as Person type.

Top comments (0)