funcadelic.js
funcadelic.js copied to clipboard
Make type class matching resilient to uglification
Uglify removes Class.name which breaks typeclass matching as explained in https://github.com/microstates/ember/pull/98.
We should not rely on Class.name since it's is not always available. Instead, we could introduce a special type name to ensure that this name is always available. It is a little more verbose but it will be more reliable while classes are still being transpiled.
An alternative API could be,
export const Functor = type(class Functor {
static typeName = 'Functor'
map(fn, f) {
let { map } = this(f);
return map(fn, f);
}
});
@cowboyd if you're good with this, I'll make a PR.
Will uglify still barf if you explicitly set the name?
static name = “Functor”