numbro
numbro copied to clipboard
Manipulate functions with typescript
Numbro accepts string and the numbro object as argument of the manipulate functions, but in the types file it's declared that only accepts numbers. As the code shows:
const numbroObj = numbro(10)
const addOperand = '10'
// here it triggers the error "Argument of type 'string' is not assignable to parameter of type 'number'"
numbroObj.add(addOperand).value()
// here with this much wrong workaround it works flawlessly
numbroObj.add(addOperand as unknown as number).value()