microsoft / tsyringe

Lightweight dependency injection container for JavaScript/TypeScript
MIT License
5.19k stars 172 forks source link

TypeScript 5.0 Support of tighter parameter decorator checking #221

Closed samesfahani-tuplehealth closed 1 year ago

samesfahani-tuplehealth commented 1 year ago

Describe the bug

The issue: https://github.com/microsoft/TypeScript/issues/52435

In TS 5.0, you will get that error when using any @inject since we should allow undefined for constructor parameter decorating.

Expected behavior

https://github.com/microsoft/tsyringe/blob/f738999f3058b223bdb81dada0164a358db2460e/src/decorators/inject.ts#L11

The type of propertyKey should be propertyKey: string | symbol | undefined. NestJS has already made their fix here: https://github.com/nestjs/nest/pull/10970

Version: ^4.5.0

mildronize commented 1 year ago

I've also found the issue with the Params Decorator Type in tsyringe, while Inversify hasn't encountered any issues yet.

Even though "experimentalDecorators": true has been enabled, there are still issues with backward compatibility for Decorators Type.

CleanShot 2566-03-17 at 12 39 42@2x

shankiflang commented 1 year ago

I've also found the issue with the Params Decorator Type in tsyringe, while Inversify hasn't encountered any issues yet.

Even though "experimentalDecorators": true has been enabled, there are still issues with backward compatibility for Decorators Type.

CleanShot 2566-03-17 at 12 39 42@2x

Same problem for me !