inversify / InversifyJS

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

Conflict test case found for type definition. #1566

Open TotooriaHyperion opened 5 months ago

TotooriaHyperion commented 5 months ago

I'm trying to improve BindingToSyntax type definition because it lost type check for toConstructor, toFactory to be compatible with type inferred from bind(XXX) ...etc

But I found conflict test cases: image

Expected Behavior

types between BindingToSyntax should be compatible with generic type param of toConstructor.

Current Behavior

The right bottom example of BindingToSyntax\<T> requires toConstructor(constructor: Newable\<T>) But the rest 3 examples of BindingToSyntax\<Newable\<T>> requires toConstructor(constructor: Newable\<T>)

Possible Solution

image

This gives the toConstructor ability to infer the type from BindingToSyntax\<T> if T is Newable or returns type never

But the Ninja test fails because it's using wrong types.

I need to change the test case of toConstructor\<Ninja>(Ninja).

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Context

Your Environment

Stack trace