Npm build removing Angular's @Injectable decorator

16 Views Asked by At

I'm trying to create a small helper package for Angular, but I've encountered a bit of an issue. I have an exported class that is an Angular service, so it has the @Injectable() decorator on it.

However, whenever I run npm run build the compiled class I have in my dist doesn't have the decorator, which causes issues with classes that inherit from it. I've set the experimentalDecorators flag in my tsconfig.json to true as I've seen recommended in other threads, but it didn't have any effect.

Any assistance would be greatly appreciated, hope you all have a great week.

1

There are 1 best solutions below

0
Nahuel Morata On

Normally the typescript code that accepts decorators is transpiled to javascript which does not have decorators, this happens when doing the Angular npm run build