Sequelize-typescript: Property 'sync' does not exist on type 'Sequelize'

Created on 9 Apr 2018  路  16Comments  路  Source: RobinBuschmann/sequelize-typescript

I got this:

image

model.ts like this:

image

Although I use ts-node to run it, it works well.

How to avoid this error message?

Most helpful comment

Same error here :(
Editing tsconfig.json didn't work either.
I'm using NestJs btw

All 16 comments

@sunzongzheng how did you fix this?

@serranoarevalo I use official sequelize width @types/sequelize in the end.

@sunzongzheng sad to hear. Since you closed this issue I assumed you鈥檝e get it working.

@serranoarevalo can you provide your compiler options please or a lot easier to check for me: can you provide an example repo which reproduces the issue?

@RobinBuschmann Hi Robin, I also moved on from sequelize-typescript but I still remember the problem.

It was directly caused by by having "esModuleInterop": true on the tsconfig.json. After a while I discovered that skipLibCheck:true "fixed" the error on my console but it swallowed an import error, after inspecting a bit into the source code the SequelizeOrigin import wasn't working.

@sunzongzheng Thanks!

@serranoarevalo Did it also say SequelizeOrigin is not a constructor function type?

@RobinBuschmann yes sir.

I have same error.
This issue seems to be linked to this issue
@types/sequelize Conflicting exports of Model #16588

well... I don't know why it works. 馃槄
I edit tsconfig.json

    "esModuleInterop": false,
    "skipLibCheck": true

and I have no error anymore.

Same error here :(
Editing tsconfig.json didn't work either.
I'm using NestJs btw

@MauJovi Can you provide an example repo, which reproduces the issue?

import { Injectable } from '@nestjs/common';
import { Sequelize, Model } from 'sequelize-typescript';

@Injectable()
export class databaseProviders {
useFactory = async () => {
const sequelize = new Sequelize({
operatorsAliases: false,
dialect: 'postgres',
username: 'user',
host: 'hostname',
database: 'db',
password: 'pass',
port: 5433,
});
await sequelize.sync();
return sequelize;
}
}

This shows me the Error "Property 'sync' does not exist on type 'Sequelize'".

my tsconfig files is like below
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": false,
"skipLibCheck":true,
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./"
},
"exclude": ["node_modules"]
}

@nikhilseepana Can you provide a repository? I cannot reproduce it with the example you provided.

Closing this due to inactivity

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fareshan picture fareshan  路  3Comments

lilling picture lilling  路  4Comments

josecolella picture josecolella  路  4Comments

CampaUTN picture CampaUTN  路  4Comments

bschveitzer picture bschveitzer  路  5Comments