Last active
April 7, 2019 23:44
-
-
Save rileyhilliard/03e8c98c34ba3422f576834085c4e977 to your computer and use it in GitHub Desktop.
Incorrect TypeScript Functional Destructure
This file contains hidden or 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' }; | |
| /* -------------- 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