I need add 40 to a string | number
type, and return a string | number
. How is it possible in Typescript?
I thought parse it to number, then increase it and return it. But how can I parse a variable which is not sure is string, but it can be number? :)
tried this:
parseInt(x) - 44
but raised an
Argument of type 'string | number' is not assignable to parameter of type 'string'.
Type 'number' is not assignable to type 'string'.ts(2345)