Last active
October 9, 2018 20:45
-
-
Save dewey92/11ef69de8ff0fc081a47cab3aefbc677 to your computer and use it in GitHub Desktop.
TS interface basic
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
| interface ProductModel { | |
| id: number; | |
| name: string; | |
| price: number; | |
| tax: number | |
| } | |
| const getFinalPrice = (product: ProductModel) => | |
| product.price + product.tax; | |
| getFinalPrice({ id: 1, name: 'A', price: 1, tax: 0.5 }); | |
| // OK | |
| getFinalPrice({}); | |
| // Argument of type '{}' is not assignable to parameter of type 'ProductModel'. | |
| // Property 'id' is missing in type '{}'. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment