Good day everyone,
I am struggling a bit with TypeScript lately, I will go straight to the point
I have this interface and this object as shown below:
interface Beer {
id:string
name:string,
amount: number //I want the amount to always be a positive number
}
const beerOrder:Beer = {
id:'1234',
name: 'Beer',
amount: -1 //this should not be allowed
}
I want the amount
in the Beer
interface to always be a positive number, I tried to search around on how you can do that but I failed so far...
If you have any ideas on how to solve this in TypeScript then that would be greatly appreciated!!
Typescript playground link here