smartxworks / sunmao-ui

A Framework for Developing Low-code Tool
https://sunmao-ui.com
Apache License 2.0
1.38k stars 93 forks source link

Should string number be converted to number when eval? #66

Open tanbowensg opened 3 years ago

tanbowensg commented 3 years ago

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?

Yuyz0112 commented 3 years ago

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

chenenpei commented 3 years ago

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

tanbowensg commented 3 years ago

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?