numbro icon indicating copy to clipboard operation
numbro copied to clipboard

Manipulate functions with typescript

Open Rafael-Ramblas opened this issue 3 years ago • 0 comments

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()

Rafael-Ramblas avatar Dec 30 '21 04:12 Rafael-Ramblas