Last active
March 12, 2020 12:41
-
-
Save rileyhilliard/da10fe11b68d1b7feb31ad119c59d516 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const person = { first: 'John', last: 'Doe' }; | |
/* -- Correct TypeScript Functional Destructure -- */ | |
// Define a 'Person' interface with the shape of | |
// the expected Person object argument | |
interface Person { | |
first: string; | |
last: string; | |
} | |
// define that the structure of the argument being destructed | |
// should match the object schema of the Person interface | |
const hello = ({ first, last }: Person) => | |
`Hello ${first} ${last}!`; | |
// outputs "Hello John Doe!" | |
hello(person); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!