Skip to content

Instantly share code, notes, and snippets.

@duanebester
Created November 14, 2019 15:24
Show Gist options
  • Save duanebester/db0ed7ebc9c1d0f16902df1d65fde8e3 to your computer and use it in GitHub Desktop.
Save duanebester/db0ed7ebc9c1d0f16902df1d65fde8e3 to your computer and use it in GitHub Desktop.
TypeScript Woes
interface Product {
id: number
}
function getId(product: Product): number {
return product.id;
}
// Does not work in development with typescript :sunglasses:
let product: Product = { id: null };
// However
// If our API Endpoint returned `{ id: null }` for some reason
let product: Product = useQuery<Product>();
// Then a calling getId would produce an error
getId(a); // :sweat:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment