thiagobustamante / typescript-ioc

A Lightweight annotation-based dependency injection container for typescript.
MIT License
524 stars 64 forks source link

Property Injection changed with recent Typescript versions. #90

Open danelowe opened 2 years ago

danelowe commented 2 years ago

I was just having a look into this library and came across an issue with recent Typescript (4.3.5)

TLDR - Property injection needs the declare keyword. (or useDefineForClassFieldsset to false in tsconfig)

@Inject
private declare helloService: HelloService;

I can look at submitting a PR for changing the readme if I get some time and look further into this library.

The issue is described well in the Typescript 3.7 release notes.

The useDefineForClassFields now defaults to true as of Typescript 4.x. I'd be inclined to leave it as true based on their description of it being the most likely standard going forward.