Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make type class matching resilient to uglification #63

Open
taras opened this issue Dec 16, 2018 · 1 comment
Open

Make type class matching resilient to uglification #63

taras opened this issue Dec 16, 2018 · 1 comment

Comments

@taras
Copy link
Member

taras commented Dec 16, 2018

Uglify removes Class.name which breaks typeclass matching as explained in microstates/ember#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.

@cowboyd
Copy link
Member

cowboyd commented Dec 17, 2018

Will uglify still barf if you explicitly set the name?

static name = “Functor”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants