Type errors in state change subscriptions upgrading to 2.0.1
See original GitHub issueHi there, I’m using state services with the includeStateChangesOnSubscribe: true setting, and after updating to the latest version, my project isn’t building and all of the subscriptions are showing type errors. Since I was using includeStateChangesOnSubscribe: true, in each subscription I was using the separate state and stateChanges objects as so:
this.fooStateServiceSubscription = this.fooStateService.stateChanged .subscribe(stateEvent => { if (stateEvent.stateChanges.pages) { this.allMyPages = stateEvent.state.pages; }
The compiler now thinks that the stateEvent object dispatched through the description is the state type itself, not the js object that had state and stateChanges on it.
I could go into all of these spots and cast the stateEvent object to any, but that seems rough. Is it possible to ratchet back down the type safety of the dispatched state event object, or somehow make an interface that would work for both versions?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
I think that’s the ideal solution.
I just released 2.1.0 which now has
stateWithPropertyChanges
. TheincludeStateChangesOnSubscribe
property is now deprecated buts works the same as in the initial 2.0.0 release. I’ll keep it in there up through a 3.0 release. The readme has details about the new observable properties. See the version history for the specifics for 2.1.Thanks for your feedback!