Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I have a problem with parametrs decorator

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

That is my tsconfig.json:

{ "compilerOptions": { "target": "ES2020", "useDefineForClassFields": false, } "experimentalDecorators": true, "emitDecoratorMetadata": true }

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading