Sequelize-typescript: sequelize_1.Model[(staticMethodPrefix + "conformOptions")] is not a function

Created on 28 Mar 2019  路  7Comments  路  Source: RobinBuschmann/sequelize-typescript

Creating a new model instance yields the following error:

sequelize_1.Model[(staticMethodPrefix + "conformOptions")] is not a function
    at Function.BaseModel.prepareInstantiationOptions (/Users/admin/src/synec-serverless/node_modules/sequelize-typescript/lib/models/BaseModel.js:117:63)
    at new Model (/Users/admin/src/synec-serverless/node_modules/sequelize-typescript/lib/models/v4/Model.js:8:45)
    at new User (/Users/admin/src/synec-serverless/node_modules/morganisations/dist/db/models/general/user.js:14:12)
    at Function.build (/Users/admin/src/synec-serverless/node_modules/sequelize/lib/model.js:2139:12)
    at Function._target.(anonymous function) [as build] (/Users/admin/src/synec-serverless/node_modules/sequelize-typescript/lib/models/BaseModel.js:42:33)
    at Function.create (/Users/admin/src/synec-serverless/node_modules/sequelize/lib/model.js:2192:17)
    at Function._target.(anonymous function) [as create] (/Users/admin/src/synec-serverless/node_modules/sequelize-typescript/lib/models/BaseModel.js:42:33)
    at Object.<anonymous> (/Users/admin/src/synec-serverless/node_modules/morganisations/dist/middlewares/cognito-auth.js:65:34)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/admin/src/synec-serverless/node_modules/morganisations/dist/middlewares/cognito-auth.js:8:26)

The presented available object keys are (using Object.keys on sequelize_1.Model):

[ 'getAssociations',
  'getAssociationForAlias',
  'Mixin',
  'default',
  '_setupHooks',
  'runHooks',
  'addHook',
  'removeHook',
  'hasHook',
  'hasHooks',
  'beforeValidate',
  'afterValidate',
  'validationFailed',
  'beforeCreate',
  'afterCreate',
  'beforeDestroy',
  'afterDestroy',
  'beforeRestore',
  'afterRestore',
  'beforeUpdate',
  'afterUpdate',
  'beforeSave',
  'afterSave',
  'beforeUpsert',
  'afterUpsert',
  'beforeBulkCreate',
  'afterBulkCreate',
  'beforeBulkDestroy',
  'afterBulkDestroy',
  'beforeBulkRestore',
  'afterBulkRestore',
  'beforeBulkUpdate',
  'afterBulkUpdate',
  'beforeFind',
  'beforeFindAfterExpandIncludeAll',
  'beforeFindAfterOptions',
  'afterFind',
  'beforeCount',
  'beforeAssociate',
  'afterAssociate',
  'beforeSync',
  'afterSync',
  'beforeBulkSync',
  'afterBulkSync' ]

The calling code:

user = yield db_1.User.create({
  uuid: cognitoUser.id,
  email: cognitoUser.email
});

extra info
I have two projects. Project A and project B. Project A defines the models, gets compiled from typescript to javascript (tsc, es6). Project B then consumes Project A's build javascript files via npm.

Any ideas?

Most helpful comment

It works up thru 5.1.1.

A change was made in 5.2 that changed a method from this.constructor._conformOptions(options, this.constructor); to this.constructor._conformIncludes(options, this.constructor); which seems to be cause of this particular error. For now, I've just locked my Sequelize version to 5.1.1 and things are working well for now. Hopefully it's just a simple method name change that won't require a ton of changes to fix.

All 7 comments

What version of sequelize are you using?
I just got this error in a brand new project and the cause of the problem was sequelize@5. I downgraded it to v4 and it worked.
sequelize-typescript supports sequelize v5 only in _canary_ version

It works up thru 5.1.1.

A change was made in 5.2 that changed a method from this.constructor._conformOptions(options, this.constructor); to this.constructor._conformIncludes(options, this.constructor); which seems to be cause of this particular error. For now, I've just locked my Sequelize version to 5.1.1 and things are working well for now. Hopefully it's just a simple method name change that won't require a ton of changes to fix.

@tcatkins99 Thanks for pointing that out!

@tcatkins99 I'm just wondering: Are you using [email protected] with sequelize@5?

@tcatkins99 I'm just wondering: Are you using [email protected] with sequelize@5?

Yes:

    "sequelize": "5.1.1",
    "sequelize-typescript": "^0.6.8",

@tcatkins99 This is strange. I was sure, that the bundled typings of sequelize@5 conflicting with the typings depended by sequelize-typescript: @types/sequelize. Have you done something special in order to prevent collision?

@tcatkins99 This is strange. I was sure, that the bundled typings of sequelize@5 conflicting with the typings depended by sequelize-typescript: @types/sequelize. Have you done something special in order to prevent collision?

Nope, (at least not intentionally, LOL). Just standard npm install ...

Was this page helpful?
0 / 5 - 0 ratings