go-tools icon indicating copy to clipboard operation
go-tools copied to clipboard

Feature request: Warn users when misusing `syscall/js.ValueOf`

Open soypat opened this issue 4 years ago • 0 comments

Warn users when passing arguments with no valid javascript ValueOf mapping to the following functions

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.

soypat avatar Mar 19 '22 22:03 soypat