inversify / InversifyJS

A powerful and lightweight inversion of control container for JavaScript & Node.js apps powered by TypeScript.
http://inversify.io/
MIT License
11.02k stars 712 forks source link

Unsafe type with some BindingToSyntax #1565

Closed TotooriaHyperion closed 3 months ago

TotooriaHyperion commented 3 months ago

image

Expected Behavior

If the generic type of ServiceIdentifier can be inferred, then the generic type of toXXX should be compatible with the generic type param of ServiceIdentifier.

Current Behavior

Specifying incompatible generic types or implicitly inferred from provided params causing unsafe types.

Possible Solution

Enhance type definition. As shown in the image, T2 -> T2 extends T

Steps to Reproduce (for bugs)

As shown in the image.

Context

Your Environment

Stack trace