Contravariant Msg type in Dispatchable and LocalActorRef #148
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Makes LocalActorRef and Dispatchable contravariant.
Description
The type of the protocol field of Dispatchable was changed to a type that TypeScript recognizes as contravariant. This field doesn't seem to be used for anything else beside coaxing the type system. Please deny the PR if this assumption is wrong.
Fixing this surfaced an error related to the fact that StatelessActorProps was not exactly assignable to ActorProps, even though it probably should be. I fixed this as well.
Related Issue
Fixes #147
Motivation and Context
The error, as outlined in the #147, causes the type system to disallow certain assigning statements that should be allowed and vice versa.
How Has This Been Tested?
npm run test
in @nact/corenpm run typecheck
in @nact/coreScreenshots (if appropriate):
The new test case I wrote went from this:
to this:
Types of changes
I guess the interface for StatelessActorProps was changed slightly, so if this is actually used in explicit form anywhere. Like a field like this,
let actorProps: StatelessActorProps<LocalActorSystemRef> = ...
, that line will fail. I find that it was basically a bug that the line would be accepted anyway because there is no such signature for ActorProps (one without State and Msg). However, with the logic that existing code that would work now would end up not compiling, it could be classified as a breaking change.Checklist: