1

After some time I try to re-develop my NodeJs app to TypeScript and I run with Sequelize into problems.

After trying to use the code from the website, I get an error:

This expression is not constructable.
  Type 'typeof import("/home/developer/devel/metricsutilities/WorklogMetrics/node_modules/sequelize/types/index")' has no construct signatures.ts(2351)

The code is a simple database connector

import * as Sequelize from 'sequelize'

export const sequelize = new Sequelize("xx", "xxx", "xxx", {
  host: "xxx",
  dialect: "postgres",
  pool: {
    max: 15,
    min: 0,
    idle: 10000,
  },
  logging: false,
  timezone: "+01:00",
});
sequelize.authenticate()

Inside a common JavaScript NodeJS app this is working. Sequelize 6.21.3 Inside my new NodeJS app not. And I think it is exact the Sequelize website says. My new server has: Node 16.10.0 on Linux Ubuntu Sequelize 6.28.0 @types/sequelize: 4.28.14

Do I miss something inside the constructor?

0

1 Answer 1

4

You import the whole module and tried to use it as a class. Just import separated classes/functions/enums/interfaces enumerating them inside {} in the import statement:

import { Sequelize, Op } from 'sequelize'
Sign up to request clarification or add additional context in comments.

1 Comment

Solves my problem and I understand now my mistake. Many thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.