To use the plugin, run the following commands for installation
npm install --save-dev @littledan/plugin-transform-operator-overloadingnpm install --save-prod @littledan/operator-overloading-shim
and add the following to your
If you encounter any issues, including unexpected behavior, poor performance, weird ergonomics, etc, please file an issue.
Recommended best practices
with operators fromdeclarations just in code that needs it, rather than at the top level of the module. This makes the transformation only apply to that code, reducing the predictability and performance impact.
- When creating a library that exposes operator overloading, expose a method-based interface as well, to support usage without this transform.
- Note that overloading  or = results in the creation of a Proxy; carefully consider whether this is appropriate for performance-sensitive code.
Deviations from proto-specification behavior
- Rather than using the syntax
with operators from ABC, use the syntax
- When outside of any block which has a
with operators fromdeclaration, this transform treats objects with overloaded operators as if they didn't have overloading (and therefore undergo coercion like objects), whereas the spec behavior would be to throw a TypeError.
- The underlying operator-overloading-shim does not protect against introspection of symbols or monkey-patching in the environment. Error checking behavior may be somewhat weaker.