node.jstypescriptsequelize.jspackage.jsonsequelize-typescript

LOCK defined as ENUM and Interface in sequelize -> types/transaction.d.ts


I am using typescript for nodejs server. I am using sequelize for MySQL database connection.

Everything works fine if I run nodemon server.ts. But npx tsc is throwing following error:

node_modules/sequelize/types/transaction.d.ts:121:13 - error TS2395: Individual declarations in merged declaration 'LOCK' must be all exported or all local.

121 export enum LOCK {
                ~~~~

node_modules/sequelize/types/transaction.d.ts:134:11 - error TS2395: Individual declarations in merged declaration 'LOCK' must be all exported or all local.

134 interface LOCK {
              ~~~~


Found 2 errors in the same file, starting at: node_modules/sequelize/types/transaction.d.ts:121

In package json file:

"sequelize": "^6.32.1",
"sequelize-typescript": "^2.1.5",
"typescript": "^5.1.6",
"@types/node": "^20.5.2",
"@types/sequelize": "^4.28.15",

I have "type": "commonjs" in my package.json file. Node version v14.21.3

There is no trace to debug. I have double checked the versions and there is no mismatch.

Point me to what I am missing or if there are any previous questions which I am not able to find.


Solution

  • This error is caused by a mismatch between your TypeScript version and the Sequelize version you're using. Sequelize 6.32.1 is using TypeScript ^4.5.4.

    Installing the same TypeScript version in my project fixed it for me:

    npm install --save-dev typescript@^4.5.4
    npx tsc