implicit conversion from underlying type to @:enum abstracts
For instance, fs.symlink accepts the type parameter that is String with predefined values in JS: dir, file and junction (see http://nodejs.org/api/fs.html#fs_fs_symlink_srcpath_dstpath_type_callback).
For those values, we provide a @:enum abstract SymlinkType (see https://github.com/HaxeFoundation/hxnodejs/blob/3ca255f7842ca25ce90f7c4ce9651b21bf150a7b/js/node/Fs.hx#L51)
The question is: should we add from String to that abstract?
- if we don't, user won't be able to just copy-paste js code and will have to change strings to enum values
- if we do, user may pass an invalid string so we lose strict typing
Another option is add a @:from method with validation, but I don't think that's a good idea because that would add runtime cost (we could only add it in -debug mode tho).
I think we shoud allow from String because nodejs can add a new option in the future and we can't enforce the user to wait our update.
Maybe we need a functionality that allows from cast only from constant values which are part of the @:enum abstract. This would allow easy usage and compile-time validation. The downside is that you couldn't pass non-constant values without casting them.
Also I think the "wait for update" argument is negligible.