Created
November 14, 2019 15:24
-
-
Save duanebester/db0ed7ebc9c1d0f16902df1d65fde8e3 to your computer and use it in GitHub Desktop.
TypeScript Woes
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 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