I want to use TSyringe to implement DI in my application. So, i use interfases, thats why i have to apply a parametrs decorator to link the interface and the class. But i have a problem "Decorators are not valid here.ts(1206)" and @injectable() for class is working without a problem.
public constructor(@inject("Controller") private _controller: Controller) { }
I used google and I tried find solution of my problem. I changed "experimentalDecorators", "emitDecoratorMetadata" to true and "useDefineForClassFields": false, but it didn't help me.
That is my tsconfig.json:
{ "compilerOptions": { "target": "ES2020", "useDefineForClassFields": false, } "experimentalDecorators": true, "emitDecoratorMetadata": true }
It looks like that you have a problem with tsconfig.json. The experimentDecorators and emitDecoratorMetadata options should be within the compilerOptions. In order to be applied correctly. Here is the updated tsconfig.json:
{
"compilerOptions": {
"target": "ES2020",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"useDefineForClassFields": false
}
}
I will be happy when this answer solves your problem.