Skip to content

Instantly share code, notes, and snippets.

@rileyhilliard
Last active April 7, 2019 23:44
Show Gist options
  • Select an option

  • Save rileyhilliard/03e8c98c34ba3422f576834085c4e977 to your computer and use it in GitHub Desktop.

Select an option

Save rileyhilliard/03e8c98c34ba3422f576834085c4e977 to your computer and use it in GitHub Desktop.
Incorrect TypeScript Functional Destructure
const person = { first: 'John', last: 'Doe' };
/* -------------- TypeScript Function -------------- */
const hello1 = (first: string, last: string) =>
`Hello ${first} ${last}!`;
// outputs "Hello John Doe!"
hello1(person.first, person.last);
/* -- Incorrect TypeScript Functional Destructure -- */
const hello2 = ({ first: string, last: string }) =>
`Hello ${first} ${last}!`;
hello2(person); // error!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment