Sequelize-typescript: Typescript 2.7.2 constructor function

Created on 19 Mar 2018  路  5Comments  路  Source: RobinBuschmann/sequelize-typescript

Got an error, originating from the sequelize type definitions.

node_modules/sequelize-typescript/lib/models/Sequelize.d.ts(7,40):
  error TS2507:
  Type '{
    default: SequelizeStatic;
    cls: any;
    useCLS(namespace: Namespace): Sequelize;
    Utils: Utils;
    Prom...'
  is not a constructor function type.

Coming from Sequelize.d.ts.

Anyone else getting this error? I'm using typescript 2.7.2 on an Ubuntu machine.

Most helpful comment

@sanewell92 thanks for creating the example repo. The compiler option esModuleInterop is causing this error. This is because esModuleInterop: true requires exports like export = to be imported with import target from 'source'. Since the sequelize typings use this format (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/sequelize/index.d.ts#L6620) it is throwing this error.
So for now, either omit that compiler option (esModuleInterop) or set skipLibCheck: true (see https://www.typescriptlang.org/docs/handbook/compiler-options.html).

But for the long term I will need to investigate this a little bit more and check how I will proceed with this issue.

All 5 comments

Hey @sanewell92 thanks for reporting. Unfortunately I cannot reproduce the issue. Can you provide an example repo which demonstrates the problem? Thank you

Try cloning this repo and then npm install && npm run build

@sanewell92 thanks for creating the example repo. The compiler option esModuleInterop is causing this error. This is because esModuleInterop: true requires exports like export = to be imported with import target from 'source'. Since the sequelize typings use this format (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/sequelize/index.d.ts#L6620) it is throwing this error.
So for now, either omit that compiler option (esModuleInterop) or set skipLibCheck: true (see https://www.typescriptlang.org/docs/handbook/compiler-options.html).

But for the long term I will need to investigate this a little bit more and check how I will proceed with this issue.

I've spent a good amount of time dealing with this compilation error of SequelizeOrigin in Sequelize class. Maybe we could add something on the installation instructions about the esModuleInterop option, I'm up for opening a PR if you think it is appropriate @RobinBuschmann.

@junior-ales Sounds good :) For [email protected] this won't be an issue anymore. But for now it is a good idea.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

YaroslavOsetrov picture YaroslavOsetrov  路  3Comments

lverledens picture lverledens  路  4Comments

nandox5 picture nandox5  路  3Comments

josecolella picture josecolella  路  4Comments

fareshan picture fareshan  路  3Comments