Skip to content

Instantly share code, notes, and snippets.

@dewey92
Last active October 9, 2018 20:45
Show Gist options
  • Select an option

  • Save dewey92/11ef69de8ff0fc081a47cab3aefbc677 to your computer and use it in GitHub Desktop.

Select an option

Save dewey92/11ef69de8ff0fc081a47cab3aefbc677 to your computer and use it in GitHub Desktop.
TS interface basic
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