I have the following code, which takes an options parameter:
const getCat = function (options: { format: "decimal" }) {
return null
}
const options = { format: "decimal" }
const cat = getCat(options)
However, the const cat = getCat(options)
runs into an error:
Argument of type '{ format: string; }' is not assignable to parameter of type '{ format: "decimal"; }'.
Types of property 'format' are incompatible.
Type 'string' is not assignable to type '"decimal"'.
How can I cast my options to be of the type TypeScript is looking for?