-
Notifications
You must be signed in to change notification settings - Fork 713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binding typing discussion #1319
Comments
Hi @tonyhallett , I think it's a good approach, should we create an v6 branch to address all the PR related to breaking changes? This way we could avoid releasing too many major versions |
The Promise (Lazy) Support + Global onActivation/onDeactivation feature is a breaking change ( well it will be when the cache type is corrected by Refactor resolve request ) and we should release v6 now. |
@tonyhallett If we are about to break, I would wait before releasing v6. We really want to improve typings, some additional BC are about to be done and I think we should try not to launch a v7 too quickly |
By all means wait for release, but The Promise (Lazy) Support + Global onActivation/onDeactivation feature is a breaking change ( with the fix we are putting through ) so shouldn't we be updating package.json ? |
Ahh, well Im not sure. What are we breaking? We add async support but I cant think in a piece of code which would stop working as long as the syncronous behavior remains unchanged |
The interface Binding has changed. Beforehand it would be possible ( and I am not saying this is what you would do ) to cast the Binding and do below
Now you get the error message A contrived example with cache
Now you get the error message I don't know what people are doing with the Context but with the change it is possible to break existing code, |
Yes - https://github.com/inversify/InversifyJS/tree/v6 and https://github.com/inversify/InversifyJS/tree/v6-binding-abstractions as per #1327 (comment) |
@notaphplover
With respect to #1132 (comment)
This is what I think the correct typing should be after #1132. Omitting unnecessary properties.
The Binding class is currently incorrect with factory and provider.
It would be great to remove T2 from toConstructor
public toConstructor<T2>(constructor: interfaces.Newable<T2>): interfaces.BindingWhenOnSyntax<T> {
and change to either
constructor:T
or
constructor:Newable<any>
Both statements result in an incorrect onActivation
By correcting there is no need to cast
The implementationType needs to change from
implementationType: Newable<T> | null;
to
implementationType: T | Newable<T> | null;
because of
container.bind<interfaces.Newable<Category>>
and resolver ( note that we are already changing the type T )
InversifyJS/src/resolution/resolver.ts
Line 84 in d06d0b0
InversifyJS/src/resolution/resolver.ts
Line 117 in d06d0b0
we are activating T
The text was updated successfully, but these errors were encountered: