sunmao-ui icon indicating copy to clipboard operation
sunmao-ui copied to clipboard

Should string number be converted to number when eval?

Open tanbowensg opened this issue 3 years ago • 3 comments

When evaling number string, we automatically convert it to real number. But sometimes, we need it to be number string. For example, in chakra radio, chakra will change number to string number. Is it nessesary to keep this logic?

tanbowensg avatar Sep 15 '21 10:09 tanbowensg

Maybe we can add some test cases in this issue to describe the desired behavior?

For example: 1 -> Number: 1 '1' -> String '1' {{ 1 }} -> Number: 1 {{ '1' }} -> String '1'

cc @chenenpei

Yuyz0112 avatar Sep 15 '21 11:09 Yuyz0112

The 4 cases mentioned above are desired, while the second one does not work as expected so far.

Since we are passing an object to the renderApp function, values' types in this object are self-evident. It might not necessary to cast a numeric string to a number.

The behaviour of chakra-ui radio can be found in this issue: https://github.com/chakra-ui/chakra-ui/issues/2931#issuecomment-761758604

chenenpei avatar Sep 16 '21 09:09 chenenpei

There is another factor to be consider. When user change property in form, do we have to convert the value of input to number or boolean?

tanbowensg avatar Nov 02 '21 02:11 tanbowensg