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

instanceMethods with es6 arrow function #5858

Closed
xiaofan2406 opened this issue May 6, 2016 · 2 comments
Closed

instanceMethods with es6 arrow function #5858

xiaofan2406 opened this issue May 6, 2016 · 2 comments

Comments

@xiaofan2406
Copy link

xiaofan2406 commented May 6, 2016

What you are doing?

With Node js moving to es6, it would be great if arrow function works when defining instanceMethods.

module.exports = (sequelize, DataTypes) => {
  const User = sequelize.define('User', {
    name: DataTypes.STRING
  }, {
    instanceMethods: {
      foo: () => { // this is not gonna work as expected
        return this.name
      }
    }
  });
  return User;
};

What do you expect to happen?

above code to work.

What is actually happening?

I may be wrong. I think the lexical scoping is not working in our favor here.

@janmeier
Copy link
Member

janmeier commented May 6, 2016

There is no way to override the scope of arrow functions - that's one of their main features. So there's nothing we can do here

@janmeier janmeier closed this as completed May 6, 2016
@vajanishant
Copy link

vajanishant commented Jun 28, 2018

can you elaborate why this thing is happening!!! @janmeier

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

3 participants