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

[v5] sequelize.import error TS4082: Default export of the module has or is using private name 'Bluebird' #176

Open
billybarnum opened this issue Nov 11, 2018 · 1 comment

Comments

@billybarnum
Copy link

All the shops where I've worked that use sequelize use sequelize.import() to define models; it allows you to create more modular definition files.

I had a really hard time upgrading model definitions from v3 to v4 because of all the generics at the top level (and admittedly my typescript inexperience) but eventually I got it all working. Those generics are mostly gone in v5 which is great, but I'm having trouble again.

The code below returns error TS4082: Default export of the module has or is using private name 'Bluebird'

I note the v5 example on the home page uses init(), and poking around it almost seems from stackoverflow and other issues here that import() is being deprecated???

I'm not stuck on import() and will try out init(), but I'm thinking there's quite a bit of code out there that's gonna break if it goes, and it should be mentioned in the migration notes and the docs.

And if it still works but I just can't figger it out, can you help a guy out and tell me what I'm doing wrong below?

Thanks.

import {
    DataTypes,
    Sequelize,
} from 'sequelize';
 
export default (
    sequelize: Sequelize,
    dataTypes: typeof DataTypes
) => {
    const model = sequelize.define(
        'Profile',
        {
          id: {
            type: dataTypes.INTEGER,
            field: 'id',
            allowNull: false,
            primaryKey: true,
            references: {
                model: 'Customer',
                key: 'primaryKey'
            },
            onDelete: 'NO ACTION',
            onUpdate: 'NO ACTION'
        },
        screenName: {
            type: dataTypes.STRING(32),
            field: 'screenName',
            allowNull: true
        },
      },{
        tableName: 'Profile'
      });

      const Profile = class extends model {
        id: number;
        screenName?: string;
      }

      return Profile;
};
@trusktr
Copy link

trusktr commented Dec 21, 2019

I've opened a request to fix this in TypeScript. microsoft/TypeScript#35822

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