HaxeFoundation / HaxeFoundation/hxnodejs
implicit conversion from underlying type to @:enum abstracts
- Dominant language
- Haxe
- Stars
- 177
- Forks
- 58
- PR merge metrics
- No merged PRs in 30d
Description
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).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.