go-tools
go-tools copied to clipboard
Feature request: Warn users when misusing `syscall/js.ValueOf`
Warn users when passing arguments with no valid javascript ValueOf mapping to the following functions
- [ ]
func ValueOf(v any) Value - [ ]
func (Value) Call(m string, args ...any) Value - [ ]
func (Value) New(args ...any) Value - [ ]
func (Value) Set(p string, x any) - [ ]
func (Value) SetIndex(i int, x any) - [ ]
func (Value) Invoke(args ...any) Value
The arguments passed in as the any (interface{}) type to these functions should be of the following types (left hand column)
| Go | JavaScript |
| ---------------------- | ---------------------- |
| js.Value | [its value] |
| js.Func | function |
| nil | null |
| bool | boolean |
| integers and floats | number |
| string | string |
| []interface{} | new array |
| map[string]interface{} | new object |
If the mentioned functions receive a any which is not of underlying type listed above then the function panics. This is undesired behaviour in any case I can think of.