Derive type info from a function
Yasunori Tanaka
Posted on July 17, 2020
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.
💖 💪 🙅 🚩
Yasunori Tanaka
Posted on July 17, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
undefined Practical Implementation of Secure Payment and Password Protection in HarmonyOS Next E-commerce Applications
November 30, 2024
undefined Practical Construction of a Secure Authentication System for Enterprise-Level Applications in HarmonyOS Next
November 30, 2024