Hi, why isn't there any operation on Number ? If I...
# javascript
a
Hi, why isn't there any operation on Number ? If I have an external interface having
x: Number, y: Number
, how would I create an operator function
plus
, should I convert or
unsafeCast<Double>
the numbers for every operation I need ? Or add operator functions to Number with
unsafeCast<Double>
every time ?
b
Because only in js all number types can be added. Unsafe casting to double in this case is ok, because it will still be a number in js (due to its lack of concrete number types)
t
If I have an external interface having
x: Number, y: Number
Common recommendation for fine external types - don’t use
Number
type as output (and input where it’s possible) So answer - fix declarations
a
okay I see, thanks !
And for parameters of functions (that are external or not) it's fine I guess ?
t
Strict type is preferable option in most cases
Single usefull option for
Number
which I know - “magic” extensions
a
Ah, I see :o Is there any documentation about good/bad practises in K/JS IR like that somewhere ?
t
Do you mean concrete practices?
a
Yes