I am attempting to incorporate decorators into my TypeScript class. Here is what I have done:
import {
Model,
ModelCtor
} from 'sequelize/types';
function decorator(constructor) {
//
}
@decorator
class Service implements IService {
// when I use 'private User: any' instead, it works fine
constructor(private User: ModelCtor < Model < any, any >> ) {
}
}
Upon running this code, I encounter the following error message:
Error: Cannot find module 'sequelize/types'
In this instance, I am importing sequelize/types
, but the same issue arises with other .d.ts
files.
I have installed the necessary types and everything functions properly without decorators. Furthermore, no errors occur when assigning the type any
to the constructor parameter: private User: any
I have researched possible solutions, but so far, I haven't found anything beneficial.
For reference, here is my tsconfig.json file:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "./build",
"sourceMap": true,
"typeRoots": [
"./node_modules/@types",
"./lib/types/index",
"./node_modules/sequelize/types/"
],
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"pretty": true,
"allowJs": true,
"noEmit": false,
"esModuleInterop": true,
},
"include": [
"./index.ts",
"./lib"
],
"exclude": [
"node_modules",
"tests",
".vscode",
"doc",
]
}